package vault import ( "bytes" "os" "testing" "code.uint32.ru/tiny/storage/storageutil" ) func TestVaultStorage(t *testing.T) { token, ok := os.LookupEnv("V_TOKEN") if !ok { t.Skip("no V_TOKEN") } addr, ok := os.LookupEnv("V_ADDR") if !ok { t.Skip("no V_ADDR") } path, ok := os.LookupEnv("V_PATH") if !ok { t.Skip("no V_PATH") } t.Log(addr) t.Log(path) client, err := storageutil.NewVaultApiClient(token, addr) st := New(client, path) if err != nil { t.Fatal(err) } testkey := "testkey" data := []byte("this is a test") if err := st.Save(testkey, data); err != nil { t.Error(err) } b, err := st.Load(testkey) if err != nil { t.Error(err) } if !bytes.Equal(data, b) { t.Errorf("values are not equal, want: %s, have: %s", string(data), string(b)) } if err := st.Delete(testkey); err != nil { t.Error(err) } b, err = st.Load(testkey) if err == nil { t.Log("nil error when loading deleted key") } }