package secrets_manager import ( "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/date_utils" "os" "testing" "time" ) var isDebug bool var secretID = "TestSecret_" + time.Now().Format(date_utils.DateLayoutTrimmed()) func TestMain(m *testing.M) { isDebug = true os.Setenv("ENVIRONMENT", "dev") os.Setenv("AWS_PROFILE", "") // <-- Use your AWS profile name here code := m.Run() os.Exit(code) } func TestAll(t *testing.T) { testCreateSecret(t) testGetSecret(t) testDeleteSecret(t) } func testCreateSecret(t *testing.T) { type SubStruct struct { Arg3a string Arg3b string } type Anything struct { Arg1 string Arg2 string Arg3 SubStruct } secret := Anything{ Arg1: "lorem", Arg2: "ipsum", Arg3: SubStruct{ Arg3a: "dolor", Arg3b: "sit", }, } secretName, err := CreateSecret(secretID, secret, isDebug) if err != nil { t.Errorf("Secret with name '%s' could not be created.", secretName) } t.Logf("Secret with name '%s' successfully created.", secretName) } func testGetSecret(t *testing.T) { secret, _ := GetSecret(secretID, isDebug) if len(secret) <= 0 { t.Errorf("Could not get secret with name %s, or secret has not content", secretID) } t.Logf("Secret with name `%s` has content: %s", secretID, secret) } func testDeleteSecret(t *testing.T) { err := DeleteSecret(secretID, true, isDebug) if err != nil { t.Errorf("Secret with name '%s' could not be deleted.", secretID) return } t.Logf("Secret with name '%s' successfully deleted.", secretID) }