Files

37 lines
1.3 KiB
Go

package common
import (
"testing"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts"
)
func TestSuccessListBatchTypeMatches(t *testing.T) {
prepare := consts.BatchTypePrepare
renew := consts.BatchTypeRenew
export := consts.BatchTypeExport
tests := []struct {
name string
actual int
requested *int
want bool
}{
{name: "unfiltered business batch", actual: consts.BatchTypeChange, want: true},
{name: "matching business filter", actual: consts.BatchTypeRenew, requested: &renew, want: true},
{name: "different business filter", actual: consts.BatchTypeChange, requested: &renew, want: false},
{name: "unfiltered prepare batch", actual: consts.BatchTypePrepare, want: false},
{name: "explicit prepare filter remains hidden", actual: consts.BatchTypePrepare, requested: &prepare, want: false},
{name: "unfiltered export batch remains hidden", actual: consts.BatchTypeExport, want: false},
{name: "explicit export filter remains hidden", actual: consts.BatchTypeExport, requested: &export, want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := successListBatchTypeMatches(tt.actual, tt.requested); got != tt.want {
t.Fatalf("successListBatchTypeMatches(%d) = %v, want %v", tt.actual, got, tt.want)
}
})
}
}