From 8f77f2258cf5aecfec98926c6bfc64c7dfe821b6 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 18 May 2023 18:04:20 -0700 Subject: [PATCH] fix: modified to fix some of the test failures. --- internal/chaindb/chaindb_test.go | 2 +- internal/router/router.go | 4 ++-- internal/setup/setup_test.go | 2 +- internal/worker/worker_test.go | 2 +- pkg/picol/parser.go | 2 +- pkg/picol/parser_test.go | 2 +- pkg/picol/picol.go | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/chaindb/chaindb_test.go b/internal/chaindb/chaindb_test.go index c735328..39fd10b 100644 --- a/internal/chaindb/chaindb_test.go +++ b/internal/chaindb/chaindb_test.go @@ -9,7 +9,7 @@ import ( gstructs "github.com/dragonheim/gagent/internal/gstructs" ) -const testChainDBPath = "test_chaindb.hcl" +const testChainDBPath = "/tmp/test_chaindb.hcl" func TestGagentDb(t *testing.T) { // Create a new GagentDb diff --git a/internal/router/router.go b/internal/router/router.go index b961256..a535833 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -29,7 +29,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting router\n") defer wg.Done() - http.HandleFunc("/hello", answerClient) + http.HandleFunc("/hello", AnswerClient) clientSock, _ := zmq.NewSocket(zmq.ROUTER) defer clientSock.Close() @@ -143,7 +143,7 @@ func unwrap(msg []string) (head string, tail []string) { return } -func answerClient(w http.ResponseWriter, r *http.Request) { +func AnswerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 5ffc8a5..37d626e 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -41,7 +41,7 @@ func TestSetupMain(t *testing.T) { } func captureOutput(f func()) string { - original := *log.Writer() + original := log.Writer() r, w, _ := os.Pipe() log.SetOutput(w) diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go index 35bab82..83411c0 100644 --- a/internal/worker/worker_test.go +++ b/internal/worker/worker_test.go @@ -49,7 +49,7 @@ func TestWorkerMain(t *testing.T) { } func captureOutput(f func()) string { - original := *log.Writer() + original := log.Writer() r, w, _ := os.Pipe() log.SetOutput(w) diff --git a/pkg/picol/parser.go b/pkg/picol/parser.go index f2cc441..e46c898 100644 --- a/pkg/picol/parser.go +++ b/pkg/picol/parser.go @@ -25,7 +25,7 @@ type parserStruct struct { } // initParser initializes a new parserStruct instance -func initParser(text string) *parserStruct { +func InitParser(text string) *parserStruct { return &parserStruct{text: text, ln: len(text), Type: ParserTokenEOL} } diff --git a/pkg/picol/parser_test.go b/pkg/picol/parser_test.go index a5247f7..fe5939e 100644 --- a/pkg/picol/parser_test.go +++ b/pkg/picol/parser_test.go @@ -66,7 +66,7 @@ func TestParser(t *testing.T) { parser := picol.InitParser(tc.input) for _, expectedType := range tc.expected { - token := parser.GetToken() + parser.GetToken() if parser.Type != expectedType { t.Errorf("Expected token type %d, got %d", expectedType, parser.Type) } diff --git a/pkg/picol/picol.go b/pkg/picol/picol.go index 7390d5f..4e2dbe4 100644 --- a/pkg/picol/picol.go +++ b/pkg/picol/picol.go @@ -116,7 +116,7 @@ func (interp *Interpreter) RegisterCommand(name string, fn CommandFunc, privdata * Eval evaluates a script */ func (interp *Interpreter) Eval(script string) (string, error) { - parser := initParser(script) + parser := InitParser(script) var result string var err error