2022-08-16 10:06:38 -04:00
|
|
|
//go:build integration
|
|
|
|
|
2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-08-16 10:06:38 -04:00
|
|
|
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
|
|
|
|
wantQuota int
|
|
|
|
wantError bool
|
|
|
|
}{
|
|
|
|
"OSS license has quota 8": {
|
|
|
|
license: CommunityLicense,
|
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
"Empty license assumes community": {
|
|
|
|
license: "",
|
|
|
|
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-09-19 05:58:44 -04:00
|
|
|
Action: test,
|
2022-08-16 10:06:38 -04:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|