shithub: mycel

Download patch

ref: d2dd7713369793c375eb3f3afe07a3cbac02d609
parent: e26194b441f150c062c25a331af970fc96965e63
author: Philip Silva <philip.silva@protonmail.com>
date: Sun Jul 10 12:32:32 EDT 2022

update tests

--- a/js/js.go
+++ b/js/js.go
@@ -60,6 +60,9 @@
 func Start(scripts ...string) (resHtm string, changed bool, err error) {
 	service = fmt.Sprintf("sparkle.%d", os.Getpid())
 	args := make([]string, 0, len(scripts)+2)
+	if log.Debug {
+		args = append(args, "-v")
+	}
 	args = append(args, "-s", service)
 	log.Infof("Start sparklefs")
 
--- a/js/js_test.go
+++ b/js/js_test.go
@@ -1,6 +1,9 @@
 package js
 
 import (
+	"context"
+	"fmt"
+	"github.com/psilva261/opossum"
 	"github.com/psilva261/opossum/browser/fs"
 	"github.com/psilva261/opossum/logger"
 	"github.com/psilva261/opossum/nodes"
@@ -7,8 +10,10 @@
 	"github.com/psilva261/opossum/style"
 	"golang.org/x/net/html"
 	"io/ioutil"
+	"net/url"
 	"strings"
 	"testing"
+	"time"
 )
 
 const simpleHTML = `
@@ -21,9 +26,30 @@
 
 func init() {
 	log.Debug = true
+	SetFetcher(&TestFetcher{})
 	go fs.Srv9p()
+	<-time.After(2*time.Second)
 }
 
+type TestFetcher struct {}
+
+func (tf *TestFetcher) Ctx() context.Context {
+	return context.Background()
+}
+
+func (tf *TestFetcher) Origin() (u *url.URL) {
+	u, _ = url.Parse("https://example.com")
+	return
+}
+
+func (tf *TestFetcher) LinkedUrl(string) (*url.URL, error) {
+	return nil, fmt.Errorf("not implemented")
+}
+
+func (tf *TestFetcher) Get(*url.URL) ([]byte, opossum.ContentType, error) {
+	return nil, opossum.ContentType{}, fmt.Errorf("not implemented")
+}
+
 func TestJQueryHide(t *testing.T) {
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
@@ -47,7 +73,6 @@
 	fs.SetDOM(nt)
 	fs.Update(simpleHTML, nil, []string{string(buf), script})
 
-	NewJS(simpleHTML, nil, nil)
 	resHtm, changed, err := Start(string(buf), script)
 	if err != nil {
 		t.Fatalf("%v", err)
--- a/package.rc
+++ b/package.rc
@@ -19,10 +19,10 @@
 	cd cmd/opossum
 	go build $a -ldflags '-s -w' -o $name
 	cd ../..
-	cd ../gojafs/cmd/gojafs
-	go build $a -ldflags '-s -w' -o gojafs
+	cd ../sparklefs/cmd/sparklefs
+	go build $a -ldflags '-s -w' -o sparklefs
 	cd ../../../opossum
-	mv cmd/opossum/$name ../gojafs/cmd/gojafs/gojafs ./$name/
+	mv cmd/opossum/$name ../sparklefs/cmd/sparklefs/sparklefs ./$name/
 	cp README.md ./$name/
 	cp opossum.jpg ./$name/
 	tar czf $tarball $name