-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: require explicit gateway URLs
This is important UX change. We no longer ship with default URLs. User has to provide explicit one, or the test suite will refuse to run. This ensures misconfigurations and testing different gateway endpoint than desired do not happen. Explicit is better than implicit.
- Loading branch information
Showing
4 changed files
with
144 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// Test cases for isSubdomainPresetEnabled function | ||
func TestIsSubdomainPresetEnabled(t *testing.T) { | ||
tests := []struct { | ||
specs string | ||
expectedEnabled bool | ||
description string | ||
}{ | ||
// Test case 1: Empty specs and subdomain preset is enabled by default | ||
{ | ||
specs: "", | ||
expectedEnabled: true, | ||
description: "Empty specs and subdomain preset is enabled by default", | ||
}, | ||
// Test case 2: User provides "-subdomain", should be disabled explicitly | ||
{ | ||
specs: "-subdomain-gateway", | ||
expectedEnabled: false, | ||
description: "User provides '-subdomain', should be disabled explicitly", | ||
}, | ||
// Test case 3: User provides "+subdomain", should be enabled explicitly | ||
{ | ||
specs: "+subdomain-gateway", | ||
expectedEnabled: true, | ||
description: "User provides '+subdomain', should be enabled explicitly", | ||
}, | ||
// Test case 4: User provides "+other", should not affect subdomain preset | ||
{ | ||
specs: "+proxy-gateway", | ||
expectedEnabled: true, | ||
description: "User provides '+proxy-gateway', should not affect subdomain-gateway preset default", | ||
}, | ||
// Test case 5: User provides "other", subdomain preset should be enabled by default | ||
{ | ||
specs: "path-gateway", | ||
expectedEnabled: false, | ||
description: "User provides 'path-gateway', subdomain preset should be disabled due to explicit (manual) list", | ||
}, | ||
// Test case 6: User provides "-other,+subdomain", should be enabled due to +subdomain | ||
{ | ||
specs: "-path-gateway,+subdomain-gateway", | ||
expectedEnabled: true, | ||
description: "User provides '-path-gateway,+subdomain-gateway', should be enabled due to +subdomain-gateway", | ||
}, | ||
// Test case 7: User provides "+other,-subdomain", should be disabled due to -subdomain | ||
{ | ||
specs: "+path-gateway,-subdomain-gateway", | ||
expectedEnabled: false, | ||
description: "User provides '+path-gateway,-subdomain-gateway', should be disabled due to -subdomain-gateway", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.description, func(t *testing.T) { | ||
actualEnabled := isSubdomainPresetEnabled(test.specs) | ||
if actualEnabled != test.expectedEnabled { | ||
t.Errorf("Expected isSubdomainPresetEnabled(%q) to be %v, but got %v", | ||
test.specs, test.expectedEnabled, actualEnabled) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters