Loading internal/commands/create_test.go +12 −7 Original line number Diff line number Diff line Loading @@ -42,18 +42,13 @@ func TestCreate(t *testing.T) { } func TestCreateFromFile(t *testing.T) { // Ref matches the value from file unless CI_COMMIT_SHA specified sha := os.Getenv("CI_COMMIT_SHA") if sha == "" { sha = "abcdefgh12345678" } releasedAt, _ := time.Parse(time.RFC3339, "2019-01-03T01:55:18.203Z") expectedRelease := gitlab.CreateReleaseRequest{ Name: "Release for test", Description: "This is a release for testing only.", TagName: "v1.2.3", TagName: getEnvOrDefault("CI_COMMIT_TAG", "v1.2.3"), ReleasedAt: &releasedAt, Ref: sha, Ref: getEnvOrDefault("CI_COMMIT_SHA", "abcdefgh12345678"), Assets: &gitlab.Assets{ Links: []*gitlab.Link{ { Loading Loading @@ -481,3 +476,13 @@ func getReleaseFromRequest(t *testing.T, mhc *gitlab.MockHTTPClient) gitlab.Crea require.NoError(t, err) return release } // getEnvOrDefault returns the value of an environment variable if it exists, // otherwise the provided default value func getEnvOrDefault(env string, val string) string { result := os.Getenv(env) if result == "" { result = val } return result } internal/testdata/release.yml +1 −0 Original line number Diff line number Diff line --- name: Release for test description: This is a release for testing only. # The tag-name given here is used unless CI_COMMIT_TAG is specified tag-name: v1.2.3 released-at: 2019-01-03T01:55:18.203Z # The ref given here is used unless CI_COMMIT_SHA is specified Loading Loading
internal/commands/create_test.go +12 −7 Original line number Diff line number Diff line Loading @@ -42,18 +42,13 @@ func TestCreate(t *testing.T) { } func TestCreateFromFile(t *testing.T) { // Ref matches the value from file unless CI_COMMIT_SHA specified sha := os.Getenv("CI_COMMIT_SHA") if sha == "" { sha = "abcdefgh12345678" } releasedAt, _ := time.Parse(time.RFC3339, "2019-01-03T01:55:18.203Z") expectedRelease := gitlab.CreateReleaseRequest{ Name: "Release for test", Description: "This is a release for testing only.", TagName: "v1.2.3", TagName: getEnvOrDefault("CI_COMMIT_TAG", "v1.2.3"), ReleasedAt: &releasedAt, Ref: sha, Ref: getEnvOrDefault("CI_COMMIT_SHA", "abcdefgh12345678"), Assets: &gitlab.Assets{ Links: []*gitlab.Link{ { Loading Loading @@ -481,3 +476,13 @@ func getReleaseFromRequest(t *testing.T, mhc *gitlab.MockHTTPClient) gitlab.Crea require.NoError(t, err) return release } // getEnvOrDefault returns the value of an environment variable if it exists, // otherwise the provided default value func getEnvOrDefault(env string, val string) string { result := os.Getenv(env) if result == "" { result = val } return result }
internal/testdata/release.yml +1 −0 Original line number Diff line number Diff line --- name: Release for test description: This is a release for testing only. # The tag-name given here is used unless CI_COMMIT_TAG is specified tag-name: v1.2.3 released-at: 2019-01-03T01:55:18.203Z # The ref given here is used unless CI_COMMIT_SHA is specified Loading