2022-08-16 10:06:38 -04:00
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
package license
|
|
|
|
|
|
|
|
import (
|
2022-08-17 07:50:43 -04:00
|
|
|
"context"
|
2022-08-16 10:06:38 -04:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-08-25 08:06:29 -04:00
|
|
|
func TestQuotaCheckIntegration(t *testing.T) {
|
2022-08-16 10:06:38 -04:00
|
|
|
testCases := map[string]struct {
|
|
|
|
license string
|
2022-08-17 07:50:43 -04:00
|
|
|
action Action
|
2022-08-16 10:06:38 -04:00
|
|
|
wantQuota int
|
|
|
|
wantError bool
|
|
|
|
}{
|
|
|
|
"OSS license has quota 8": {
|
|
|
|
license: CommunityLicense,
|
|
|
|
action: test,
|
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
"OSS license missing action": {
|
|
|
|
license: CommunityLicense,
|
|
|
|
action: "",
|
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
"Empty license assumes community": {
|
|
|
|
license: "",
|
|
|
|
action: test,
|
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
"Empty request": {
|
|
|
|
license: "",
|
|
|
|
action: "",
|
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
client := NewClient()
|
|
|
|
|
2022-08-25 08:06:29 -04:00
|
|
|
req := QuotaCheckRequest{
|
2022-08-16 10:06:38 -04:00
|
|
|
Action: tc.action,
|
|
|
|
License: tc.license,
|
2022-08-17 07:50:43 -04:00
|
|
|
}
|
2022-08-25 08:06:29 -04:00
|
|
|
resp, err := client.QuotaCheck(context.Background(), req)
|
2022-08-16 10:06:38 -04:00
|
|
|
|
|
|
|
if tc.wantError {
|
|
|
|
assert.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
assert.NoError(err)
|
|
|
|
assert.Equal(tc.wantQuota, resp.Quota)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|