mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 15:26:04 +08:00
1a1ba1ccf4
* Move ee code to ee package and unify ee status to IsPro * Consolidate naming for paid/professional/enterprise version as "pro". Notes: - Changes image tags - Changes build tags - Changes package names - Doesn't change links to docs that mention "ee" - Doesn't change parameters sent to PostHog that mention "ee" * Revert docker image tag being -pro, back to -ee * Revert go build tag being pro, back to ee * Add build tags for some ee content * [2] Revert go build tag being pro, back to ee * Fix test workflow * Add a json tag to be backwards compatible with frontend "IsEE" check * Add a json tag for the serverconfig struct for IsEE * Ammend json tag to Is_EE * fix ee tags --------- Co-authored-by: Abhishek Kondur <abhi281342@gmail.com>
78 lines
1.5 KiB
Go
78 lines
1.5 KiB
Go
//go:build ee
|
|
// +build ee
|
|
|
|
package pro
|
|
|
|
import (
|
|
"github.com/gravitl/netmaker/config"
|
|
"testing"
|
|
)
|
|
|
|
func Test_getAccountsHost(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
envK string
|
|
envV string
|
|
conf string
|
|
want string
|
|
}{
|
|
{
|
|
name: "no env var and no conf",
|
|
envK: "NOT_THE_CORRECT_ENV_VAR",
|
|
envV: "dev",
|
|
want: "https://api.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "dev env var",
|
|
envK: "ENVIRONMENT",
|
|
envV: "dev",
|
|
want: "https://api.dev.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "staging env var",
|
|
envK: "ENVIRONMENT",
|
|
envV: "staging",
|
|
want: "https://api.staging.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "prod env var",
|
|
envK: "ENVIRONMENT",
|
|
envV: "prod",
|
|
want: "https://api.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "dev conf",
|
|
conf: "dev",
|
|
want: "https://api.dev.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "staging conf",
|
|
conf: "staging",
|
|
want: "https://api.staging.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "prod conf",
|
|
conf: "prod",
|
|
want: "https://api.accounts.netmaker.io",
|
|
},
|
|
{
|
|
name: "env var vs conf precedence",
|
|
envK: "ENVIRONMENT",
|
|
envV: "prod",
|
|
conf: "staging",
|
|
want: "https://api.accounts.netmaker.io",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
config.Config.Server.Environment = tt.conf
|
|
if tt.envK != "" {
|
|
t.Setenv(tt.envK, tt.envV)
|
|
}
|
|
if got := getAccountsHost(); got != tt.want {
|
|
t.Errorf("getAccountsHost() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|