-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mock): update payloads and test for struct changes (#1060)
* fix(mock): update payloads and test for struct changes * fix json unmarshal error message
- Loading branch information
Showing
21 changed files
with
429 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/go-vela/types/library" | ||
) | ||
|
||
func TestBuild_ActiveBuildResp(t *testing.T) { | ||
testBuild := library.Build{} | ||
|
||
err := json.Unmarshal([]byte(BuildResp), &testBuild) | ||
if err != nil { | ||
t.Errorf("error unmarshaling build: %v", err) | ||
} | ||
|
||
tBuild := reflect.TypeOf(testBuild) | ||
|
||
for i := 0; i < tBuild.NumField(); i++ { | ||
if reflect.ValueOf(testBuild).Field(i).IsNil() { | ||
t.Errorf("BuildResp missing field %s", tBuild.Field(i).Name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/go-vela/types/library" | ||
) | ||
|
||
func TestDeployment_ActiveDeploymentResp(t *testing.T) { | ||
testDeployment := library.Deployment{} | ||
|
||
err := json.Unmarshal([]byte(DeploymentResp), &testDeployment) | ||
if err != nil { | ||
t.Errorf("error unmarshaling deployment: %v", err) | ||
} | ||
|
||
tDeployment := reflect.TypeOf(testDeployment) | ||
|
||
for i := 0; i < tDeployment.NumField(); i++ { | ||
if reflect.ValueOf(testDeployment).Field(i).IsNil() { | ||
t.Errorf("DeploymentResp missing field %s", tDeployment.Field(i).Name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/go-vela/types/library" | ||
) | ||
|
||
func TestHook_ActiveHookResp(t *testing.T) { | ||
testHook := library.Hook{} | ||
|
||
err := json.Unmarshal([]byte(HookResp), &testHook) | ||
if err != nil { | ||
t.Errorf("error unmarshaling hook: %v", err) | ||
} | ||
|
||
tHook := reflect.TypeOf(testHook) | ||
|
||
for i := 0; i < tHook.NumField(); i++ { | ||
if reflect.ValueOf(testHook).Field(i).IsNil() { | ||
t.Errorf("HookResp missing field %s", tHook.Field(i).Name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/go-vela/types/library" | ||
) | ||
|
||
func TestLog_ActiveLogResp(t *testing.T) { | ||
testLog := library.Log{} | ||
|
||
err := json.Unmarshal([]byte(LogResp), &testLog) | ||
if err != nil { | ||
t.Errorf("error unmarshaling log: %v", err) | ||
} | ||
|
||
tLog := reflect.TypeOf(testLog) | ||
|
||
for i := 0; i < tLog.NumField(); i++ { | ||
if reflect.ValueOf(testLog).Field(i).IsNil() { | ||
t.Errorf("LogResp missing field %s", tLog.Field(i).Name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/go-vela/types/library" | ||
) | ||
|
||
func TestPipeline_ActivePipelineResp(t *testing.T) { | ||
testPipeline := library.Pipeline{} | ||
|
||
err := json.Unmarshal([]byte(PipelineResp), &testPipeline) | ||
if err != nil { | ||
t.Errorf("error unmarshaling pipeline: %v", err) | ||
} | ||
|
||
tPipeline := reflect.TypeOf(testPipeline) | ||
|
||
for i := 0; i < tPipeline.NumField(); i++ { | ||
if reflect.ValueOf(testPipeline).Field(i).IsNil() { | ||
t.Errorf("PipelineResp missing field %s", tPipeline.Field(i).Name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/go-vela/types/library" | ||
) | ||
|
||
func TestRepo_ActiveRepoResp(t *testing.T) { | ||
testRepo := library.Repo{} | ||
|
||
err := json.Unmarshal([]byte(RepoResp), &testRepo) | ||
if err != nil { | ||
t.Errorf("error unmarshaling repo: %v", err) | ||
} | ||
|
||
tRepo := reflect.TypeOf(testRepo) | ||
|
||
for i := 0; i < tRepo.NumField(); i++ { | ||
if tRepo.Field(i).Name == "Hash" { | ||
continue | ||
} | ||
if reflect.ValueOf(testRepo).Field(i).IsNil() { | ||
t.Errorf("RepoResp missing field %s", tRepo.Field(i).Name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.