Skip to content

Commit

Permalink
chore: give context to errors(fix unit test)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashin Sabu <ashin.sabu@harness.io>
  • Loading branch information
ashinsabu3 committed Aug 12, 2023
1 parent 0c79c87 commit 12131b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions applicationset/generators/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestGitGenerateParamsFromDirectories(t *testing.T) {
repoApps: []string{},
repoError: fmt.Errorf("error"),
expected: []map[string]interface{}{},
expectedError: fmt.Errorf("error"),
expectedError: fmt.Errorf("error generating params from git: error getting directories from repo: error"),
},
}

Expand Down Expand Up @@ -547,7 +547,7 @@ func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
repoApps: []string{},
repoError: fmt.Errorf("error"),
expected: []map[string]interface{}{},
expectedError: fmt.Errorf("error"),
expectedError: fmt.Errorf("error generating params from git: error getting directories from repo: error"),
},
}

Expand Down Expand Up @@ -742,7 +742,7 @@ func TestGitGenerateParamsFromFiles(t *testing.T) {
repoFileContents: map[string][]byte{},
repoPathsError: fmt.Errorf("paths error"),
expected: []map[string]interface{}{},
expectedError: fmt.Errorf("paths error"),
expectedError: fmt.Errorf("error generating params from git: paths error"),
},
{
name: "test invalid JSON file returns error",
Expand All @@ -752,7 +752,7 @@ func TestGitGenerateParamsFromFiles(t *testing.T) {
},
repoPathsError: nil,
expected: []map[string]interface{}{},
expectedError: fmt.Errorf("unable to process file 'cluster-config/production/config.json': unable to parse file: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"),
expectedError: fmt.Errorf("error generating params from git: unable to process file 'cluster-config/production/config.json': unable to parse file: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"),
},
{
name: "test JSON array",
Expand Down Expand Up @@ -1048,7 +1048,7 @@ func TestGitGenerateParamsFromFilesGoTemplate(t *testing.T) {
repoFileContents: map[string][]byte{},
repoPathsError: fmt.Errorf("paths error"),
expected: []map[string]interface{}{},
expectedError: fmt.Errorf("paths error"),
expectedError: fmt.Errorf("error generating params from git: paths error"),
},
{
name: "test invalid JSON file returns error",
Expand All @@ -1058,7 +1058,7 @@ func TestGitGenerateParamsFromFilesGoTemplate(t *testing.T) {
},
repoPathsError: nil,
expected: []map[string]interface{}{},
expectedError: fmt.Errorf("unable to process file 'cluster-config/production/config.json': unable to parse file: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"),
expectedError: fmt.Errorf("error generating params from git: unable to process file 'cluster-config/production/config.json': unable to parse file: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}"),
},
{
name: "test JSON array",
Expand Down
8 changes: 4 additions & 4 deletions applicationset/generators/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
},
},
expectedError: fmt.Errorf("error fetching Secret token: error fetching secret default/argocd-secret: secrets \"argocd-secret\" not found"),
expectedError: fmt.Errorf("error getting plugin from generator: error fetching Secret token: error fetching secret default/argocd-secret: secrets \"argocd-secret\" not found"),
},
{
name: "no configmap",
Expand Down Expand Up @@ -522,7 +522,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
},
},
expectedError: fmt.Errorf("error fetching ConfigMap: configmaps \"\" not found"),
expectedError: fmt.Errorf("error getting plugin from generator: error fetching ConfigMap: configmaps \"\" not found"),
},
{
name: "no baseUrl",
Expand Down Expand Up @@ -577,7 +577,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
},
},
expectedError: fmt.Errorf("error fetching ConfigMap: baseUrl not found in ConfigMap"),
expectedError: fmt.Errorf("error getting plugin from generator: error fetching ConfigMap: baseUrl not found in ConfigMap"),
},
{
name: "no token",
Expand Down Expand Up @@ -624,7 +624,7 @@ func TestPluginGenerateParams(t *testing.T) {
},
},
},
expectedError: fmt.Errorf("error fetching ConfigMap: token not found in ConfigMap"),
expectedError: fmt.Errorf("error getting plugin from generator: error fetching ConfigMap: token not found in ConfigMap"),
},
}

Expand Down

0 comments on commit 12131b2

Please sign in to comment.