(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func Test_CommitHydratedManifests(t *testing.T) { |
| 20 | t.Parallel() |
| 21 | |
| 22 | validRequest := &apiclient.CommitHydratedManifestsRequest{ |
| 23 | Repo: &v1alpha1.Repository{ |
| 24 | Repo: "https://github.com/argoproj/argocd-example-apps.git", |
| 25 | }, |
| 26 | TargetBranch: "main", |
| 27 | SyncBranch: "env/test", |
| 28 | CommitMessage: "test commit message", |
| 29 | } |
| 30 | |
| 31 | t.Run("missing repo", func(t *testing.T) { |
| 32 | t.Parallel() |
| 33 | |
| 34 | service, _ := newServiceWithMocks(t) |
| 35 | request := &apiclient.CommitHydratedManifestsRequest{} |
| 36 | _, err := service.CommitHydratedManifests(t.Context(), request) |
| 37 | require.Error(t, err) |
| 38 | assert.ErrorContains(t, err, "repo is required") |
| 39 | }) |
| 40 | |
| 41 | t.Run("missing repo URL", func(t *testing.T) { |
| 42 | t.Parallel() |
| 43 | |
| 44 | service, _ := newServiceWithMocks(t) |
| 45 | request := &apiclient.CommitHydratedManifestsRequest{ |
| 46 | Repo: &v1alpha1.Repository{}, |
| 47 | } |
| 48 | _, err := service.CommitHydratedManifests(t.Context(), request) |
| 49 | require.Error(t, err) |
| 50 | assert.ErrorContains(t, err, "repo URL is required") |
| 51 | }) |
| 52 | |
| 53 | t.Run("missing target branch", func(t *testing.T) { |
| 54 | t.Parallel() |
| 55 | |
| 56 | service, _ := newServiceWithMocks(t) |
| 57 | request := &apiclient.CommitHydratedManifestsRequest{ |
| 58 | Repo: &v1alpha1.Repository{ |
| 59 | Repo: "https://github.com/argoproj/argocd-example-apps.git", |
| 60 | }, |
| 61 | } |
| 62 | _, err := service.CommitHydratedManifests(t.Context(), request) |
| 63 | require.Error(t, err) |
| 64 | assert.ErrorContains(t, err, "target branch is required") |
| 65 | }) |
| 66 | |
| 67 | t.Run("missing sync branch", func(t *testing.T) { |
| 68 | t.Parallel() |
| 69 | |
| 70 | service, _ := newServiceWithMocks(t) |
| 71 | request := &apiclient.CommitHydratedManifestsRequest{ |
| 72 | Repo: &v1alpha1.Repository{ |
| 73 | Repo: "https://github.com/argoproj/argocd-example-apps.git", |
| 74 | }, |
| 75 | TargetBranch: "main", |
| 76 | } |
nothing calls this directly
no test coverage detected