chore(all): provider to servers map in allServers
- Simplify formatting CLI - Simplify updater code - Simplify filter choices for config validation - Simplify all servers deep copying - Custom JSON marshaling methods for `AllServers` - Simplify provider constructor switch - Simplify storage merging - Simplify storage reading and extraction - Simplify updating code
This commit is contained in:
@@ -26,9 +26,9 @@ const (
|
||||
Windscribe = "windscribe"
|
||||
)
|
||||
|
||||
// All returns all the providers except the custom provider.
|
||||
func All() []string {
|
||||
return []string{
|
||||
Custom,
|
||||
Cyberghost,
|
||||
Expressvpn,
|
||||
Fastestvpn,
|
||||
@@ -51,3 +51,11 @@ func All() []string {
|
||||
Windscribe,
|
||||
}
|
||||
}
|
||||
|
||||
func AllWithCustom() []string {
|
||||
allProviders := All()
|
||||
allProvidersWithCustom := make([]string, len(allProviders)+1)
|
||||
copy(allProvidersWithCustom, allProviders)
|
||||
allProvidersWithCustom[len(allProvidersWithCustom)-1] = Custom
|
||||
return allProvidersWithCustom
|
||||
}
|
||||
|
||||
23
internal/constants/providers/providers_test.go
Normal file
23
internal/constants/providers/providers_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_All(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
all := All()
|
||||
assert.NotContains(t, all, Custom)
|
||||
assert.NotEmpty(t, all)
|
||||
}
|
||||
|
||||
func Test_AllWithCustom(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
all := AllWithCustom()
|
||||
assert.Contains(t, all, Custom)
|
||||
assert.Len(t, all, len(All())+1)
|
||||
}
|
||||
Reference in New Issue
Block a user