constellation/internal/license/license_integration_test.go
Thomas Tendyck bd63aa3c6b add license headers
sed -i '1i/*\nCopyright (c) Edgeless Systems GmbH\n\nSPDX-License-Identifier: AGPL-3.0-only\n*/\n' `grep -rL --include='*.go' 'DO NOT EDIT'`
gofumpt -w .
2022-09-05 09:17:25 +02:00

68 lines
1.1 KiB
Go

//go:build integration
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package license
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestQuotaCheckIntegration(t *testing.T) {
testCases := map[string]struct {
license string
action Action
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()
req := QuotaCheckRequest{
Action: tc.action,
License: tc.license,
}
resp, err := client.QuotaCheck(context.Background(), req)
if tc.wantError {
assert.Error(err)
return
}
assert.NoError(err)
assert.Equal(tc.wantQuota, resp.Quota)
})
}
}