func TestGetString(t *testing.T) { var tmp = os.TempDir() kvson, err := NewKVSON(tmp) if err != nil { t.Error(err) } var data string err = kvson.Get("foo", &data) if err != nil { t.Errorf("It should not fail, but got an error: %s", err) } if data != "bar" { t.Errorf("Value should be equal to 'bar', but got: %s", data) } }
func TestGetStruct(t *testing.T) { var tmp = os.TempDir() kvson, err := NewKVSON(tmp) if err != nil { t.Error(err) } var example Example err = kvson.Get("example", &example) if err != nil { t.Errorf("It should not fail, but got an error: %s", err) } if example.ID != 1 { t.Errorf("Payload ID should be 1, but got: %d", example.ID) } if example.Key != "key" { t.Errorf("Payload ID should be 'key', but got: %s", example.Key) } }