mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-28 00:49:26 -05:00
6cfc80454a
The integration test for the license module depends on network connectivity and should be Bazel-tagged as such. Since the unit tests do not have a network dependency, we should not apply the tag to those. The easiest way to do this in a Gazelle-compliant way is to move the integration test into its own module.
56 lines
1006 B
Go
56 lines
1006 B
Go
//go:build integration
|
|
|
|
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package integration
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/license"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestQuotaCheckIntegration(t *testing.T) {
|
|
testCases := map[string]struct {
|
|
license string
|
|
wantQuota int
|
|
wantError bool
|
|
}{
|
|
"OSS license has quota 8": {
|
|
license: 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 := license.NewClient()
|
|
|
|
req := license.QuotaCheckRequest{
|
|
Action: license.Action("test"),
|
|
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)
|
|
})
|
|
}
|
|
}
|