package router import ( "testing" "github.com/gogf/gf/v2/util/gmeta" v1 "git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/iot/v1" ) func TestFullSyncMonitorPermissionDeclarations(t *testing.T) { // A slice of pairs rather than a map: request structs may contain slice // fields (for example the channel scope), which are not hashable. checks := []struct { request any want string }{ {v1.FullSyncRunsListReq{}, "cpm:iot:fullSyncRuns:view"}, {v1.FullSyncRunDetailReq{}, "cpm:iot:fullSyncRuns:view"}, {v1.FullSyncRunFailuresReq{}, "cpm:iot:fullSyncRuns:failures"}, {v1.FullSyncRunStartReq{}, "cpm:iot:fullSyncRuns:start"}, {v1.FullSyncChannelOptionsReq{}, "cpm:iot:fullSyncRuns:view"}, } for _, check := range checks { if got := gmeta.Get(check.request, "x-check-permission").String(); got != check.want { t.Fatalf("%T permission = %q, want %q", check.request, got, check.want) } } }