From 9cb1d264052efd4b031108ad8e7a98fabf3c4777 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sat, 1 Jul 2023 13:06:39 -0600 Subject: [PATCH] Added test to display GQLThread serialized data --- gql.go | 2 +- gql_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/gql.go b/gql.go index 7d80e2b..ccb1072 100644 --- a/gql.go +++ b/gql.go @@ -350,7 +350,7 @@ func NewGQLThreadInfo(start bool) GQLThreadInfo { type GQLThreadStateJSON struct { BaseThreadStateJSON - Listen string + Listen string `json:"listen"` } type GQLThreadState struct { diff --git a/gql_test.go b/gql_test.go index a06d6a3..e303f87 100644 --- a/gql_test.go +++ b/gql_test.go @@ -3,6 +3,8 @@ package graphvent import ( "testing" "time" + "fmt" + "encoding/json" ) func TestGQLThread(t * testing.T) { @@ -32,3 +34,31 @@ func TestGQLThread(t * testing.T) { err = RunThread(ctx, gql_thread) fatalErr(t, err) } + +func TestGQLDBLoad(t * testing.T) { + ctx := logTestContext(t, []string{}) + l1, err := NewSimpleBaseLockable(ctx, "Test Lockable 1", []Lockable{}) + fatalErr(t, err) + + t1, err := NewGQLThread(ctx, ":8080", []Lockable{l1}) + fatalErr(t, err) + + SendUpdate(ctx, t1, CancelSignal(nil)) + err = RunThread(ctx, t1) + fatalErr(t, err) + + err = UseStates(ctx, []GraphNode{t1}, func(states NodeStateMap) error { + ser, err := json.MarshalIndent(states[t1.ID()], "", " ") + fmt.Printf("\n%s\n\n", ser) + return err + }) + + t1_loaded, err := LoadNode(ctx, t1.ID()) + fatalErr(t, err) + + err = UseStates(ctx, []GraphNode{t1_loaded}, func(states NodeStateMap) error { + ser, err := json.MarshalIndent(states[t1_loaded.ID()], "", " ") + fmt.Printf("\n%s\n\n", ser) + return err + }) +}