fix: modified to fix some of the test failures.

This commit is contained in:
James Wells 2023-05-18 18:04:20 -07:00
parent bdeaf2ec92
commit 8f77f2258c
Signed by: jwells
GPG key ID: 73196D10B8E65666
7 changed files with 8 additions and 8 deletions

View file

@ -9,7 +9,7 @@ import (
gstructs "github.com/dragonheim/gagent/internal/gstructs" gstructs "github.com/dragonheim/gagent/internal/gstructs"
) )
const testChainDBPath = "test_chaindb.hcl" const testChainDBPath = "/tmp/test_chaindb.hcl"
func TestGagentDb(t *testing.T) { func TestGagentDb(t *testing.T) {
// Create a new GagentDb // Create a new GagentDb

View file

@ -29,7 +29,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) {
log.Printf("[INFO] Starting router\n") log.Printf("[INFO] Starting router\n")
defer wg.Done() defer wg.Done()
http.HandleFunc("/hello", answerClient) http.HandleFunc("/hello", AnswerClient)
clientSock, _ := zmq.NewSocket(zmq.ROUTER) clientSock, _ := zmq.NewSocket(zmq.ROUTER)
defer clientSock.Close() defer clientSock.Close()
@ -143,7 +143,7 @@ func unwrap(msg []string) (head string, tail []string) {
return return
} }
func answerClient(w http.ResponseWriter, r *http.Request) { func AnswerClient(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" { if r.URL.Path != "/" {
http.NotFound(w, r) http.NotFound(w, r)
return return

View file

@ -41,7 +41,7 @@ func TestSetupMain(t *testing.T) {
} }
func captureOutput(f func()) string { func captureOutput(f func()) string {
original := *log.Writer() original := log.Writer()
r, w, _ := os.Pipe() r, w, _ := os.Pipe()
log.SetOutput(w) log.SetOutput(w)

View file

@ -49,7 +49,7 @@ func TestWorkerMain(t *testing.T) {
} }
func captureOutput(f func()) string { func captureOutput(f func()) string {
original := *log.Writer() original := log.Writer()
r, w, _ := os.Pipe() r, w, _ := os.Pipe()
log.SetOutput(w) log.SetOutput(w)

View file

@ -25,7 +25,7 @@ type parserStruct struct {
} }
// initParser initializes a new parserStruct instance // 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} return &parserStruct{text: text, ln: len(text), Type: ParserTokenEOL}
} }

View file

@ -66,7 +66,7 @@ func TestParser(t *testing.T) {
parser := picol.InitParser(tc.input) parser := picol.InitParser(tc.input)
for _, expectedType := range tc.expected { for _, expectedType := range tc.expected {
token := parser.GetToken() parser.GetToken()
if parser.Type != expectedType { if parser.Type != expectedType {
t.Errorf("Expected token type %d, got %d", expectedType, parser.Type) t.Errorf("Expected token type %d, got %d", expectedType, parser.Type)
} }

View file

@ -116,7 +116,7 @@ func (interp *Interpreter) RegisterCommand(name string, fn CommandFunc, privdata
* Eval evaluates a script * Eval evaluates a script
*/ */
func (interp *Interpreter) Eval(script string) (string, error) { func (interp *Interpreter) Eval(script string) (string, error) {
parser := initParser(script) parser := InitParser(script)
var result string var result string
var err error var err error