package p4go import ( "fmt" "testing" "time" ) func TestGetClient(t *testing.T) { dao, err := AllocAndConnect("gotest", "commonsadmin", "commonsadmin", "localhost:1666", "testing") if err != nil { t.Errorf("connect failed: %s\n", err.Error()) t.FailNow() } clientName := fmt.Sprintf("unit_test_client_%d", time.Now().Nanosecond()) clientMap, err := dao.GetClient(clientName) if err != nil { t.Errorf("get failed on new client %s: %s\n", clientName, err.Error()) t.FailNow() } // change root to tmp directory newRoot := fmt.Sprintf("/tmp/%s", clientName) clientMap["Root"] = newRoot err = dao.SaveClient(clientName, clientMap) if err != nil { t.Errorf("save failed: %s\n", err.Error()) t.FailNow() } loadedMap, err := dao.GetClient(clientName) if err != nil { t.Errorf("get failed on saved client %s: %s\n", clientName, err.Error()) t.FailNow() } if loadedMap["Root"] != newRoot { t.Errorf("Saved root was not updated, was %s expected %s", loadedMap["Root"], newRoot) t.Fail() } }