Skip to content

Instantly share code, notes, and snippets.

@zzerjae
Created October 31, 2020 08:15
Show Gist options
  • Save zzerjae/fcf46494e5014aef6e48d892cfcceb6b to your computer and use it in GitHub Desktop.
Save zzerjae/fcf46494e5014aef6e48d892cfcceb6b to your computer and use it in GitHub Desktop.
package worker
func TestWorker_listRegionIdsByPublishRange(t *testing.T) {
type fields struct {
RegionSvc RegionService
NotificationSvc NotificationService
UserSvc UserService
DB DB
}
type args struct {
regionId int64
publishRange int
}
tests := []struct {
name string
fields fields
args args
want [][]int64
wantErr bool
}{
{
"정자동의 내 동네",
fields{
RegionSvc: nil,
},
args{
regionId: 1234,
publishRange: 1,
},
[][]int64{
{1234},
{1235, 1236},
},
false,
},
{
"정자동의 인접 지역",
fields{
RegionSvc: nil,
},
args{
regionId: 1234,
publishRange: 2,
},
[][]int64{
{1234},
{1235, 1236},
{1300, 1301, 1302},
},
false,
},
{
"정자동의 3단계",
fields{
RegionSvc: nil,
},
args{
regionId: 1234,
publishRange: 3,
},
[][]int64{
{1234},
{1235, 1236},
{1300, 1301, 1302},
{1400, 1401, 1402},
},
false,
},
{
"정자동의 4단계",
fields{
RegionSvc: nil,
},
args{
regionId: 1234,
publishRange: 4,
},
[][]int64{
{1234},
{1235, 1236},
{1300, 1301, 1302},
{1400, 1401, 1402},
{1500, 1501, 1502},
},
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := &Worker{
RegionSvc: tt.fields.RegionSvc,
NotificationSvc: tt.fields.NotificationSvc,
UserSvc: tt.fields.UserSvc,
DB: tt.fields.DB,
}
got, err := w.listRegionIdsByPublishRange(tt.args.regionId, tt.args.publishRange)
if (err != nil) != tt.wantErr {
t.Errorf("listRegionIdsByPublishRange() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("listRegionIdsByPublishRange() got = %v, want %v", got, tt.want)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment