This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dataset link merge bug #378 (#18)
* - return the overridden value * - add test case * - fix bug
- Loading branch information
1 parent
aebac3f
commit 25da0d1
Showing
2 changed files
with
54 additions
and
4 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,50 @@ | ||
package graphql | ||
|
||
import ( | ||
"testing" | ||
|
||
graphql1 "github.com/reearth/reearth-backend/internal/adapter/graphql" | ||
"github.com/reearth/reearth-backend/internal/graphql/dataloader" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_actualValue(t *testing.T) { | ||
value := 300 | ||
|
||
type args struct { | ||
datasetLoader dataloader.DatasetDataLoader | ||
value interface{} | ||
links []*graphql1.PropertyFieldLink | ||
overridden bool | ||
} | ||
var tests = []struct { | ||
name string | ||
args args | ||
want interface{} | ||
wantErr bool | ||
}{ | ||
{ | ||
"Overridden value", | ||
args{ | ||
datasetLoader: nil, | ||
value: value, | ||
links: nil, | ||
overridden: true, | ||
}, | ||
300, | ||
false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := actualValue(tt.args.datasetLoader, tt.args.value, tt.args.links, tt.args.overridden) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("actualValue() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
temp := got.(*interface{}) | ||
t2 := (*temp).(int) | ||
assert.Equal(t, tt.want, t2) | ||
}) | ||
} | ||
} |