Skip to content
Snippets Groups Projects

Resolve "Unit-Test: Test_core_Get is not reliable"

Merged Ghost User requested to merge 157-unit-test-test_core_get-is-not-reliable into develop
1 file
+ 27
7
Compare changes
  • Side-by-side
  • Inline
@@ -63,6 +63,7 @@ func Test_core_Get(t *testing.T) {
@@ -63,6 +63,7 @@ func Test_core_Get(t *testing.T) {
name string
name string
args args
args args
want []string
want []string
 
length int
wantErr bool
wantErr bool
}{
}{
{
{
@@ -70,15 +71,28 @@ func Test_core_Get(t *testing.T) {
@@ -70,15 +71,28 @@ func Test_core_Get(t *testing.T) {
args: args{
args: args{
ctx: context.Background(),
ctx: context.Background(),
request: &pb.GetRequest{
request: &pb.GetRequest{
All: true,
Pid: []string{
 
pndID,
 
},
},
},
},
},
 
length: 1,
want: []string{
want: []string{
pndID,
pndID,
"test",
"test",
"test",
"test",
},
},
},
},
 
{
 
name: "getAll",
 
args: args{
 
ctx: context.Background(),
 
request: &pb.GetRequest{
 
All: true,
 
},
 
},
 
length: 2,
 
},
}
}
for _, tt := range tests {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
@@ -91,13 +105,19 @@ func Test_core_Get(t *testing.T) {
@@ -91,13 +105,19 @@ func Test_core_Get(t *testing.T) {
return
return
}
}
got := []string{
if tt.name == "default" {
resp.Pnd[0].Id,
got := []string{
resp.Pnd[0].Name,
resp.Pnd[0].Id,
resp.Pnd[0].Description,
resp.Pnd[0].Name,
 
resp.Pnd[0].Description,
 
}
 
if !reflect.DeepEqual(got, tt.want) {
 
t.Errorf("core.Get() = %v, want %v", got, tt.want)
 
}
}
}
if !reflect.DeepEqual(got, tt.want) {
length := len(resp.Pnd)
t.Errorf("core.Get() = %v, want %v", got, tt.want)
if tt.length != length {
 
t.Errorf("core.Get() = %v, want %v", length, tt.length)
}
}
})
})
}
}
Loading