- Notifications
You must be signed in to change notification settings - Fork24
feat: add confliction withsubdomain#469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
+133 −24
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
00ea9f1 feat: add confliction with `subdomain`
jakehwll31fc7f8 fix: provide correct error
jakehwll0619061 feat: implement testing suite
jakehwll3d63e36 chore: remove unnecessary test suite
jakehwlle1377f5 fix: resolve `app.md` lint
jakehwll7fec6cf chore: resolve `app.go` description
jakehwll291d926 Revert "chore: remove unnecessary test suite"
jakehwllea9ea65 chore: remove unused comments
jakehwll5c3e18c chore: rename `Command` to `ConflictsWith`
jakehwll63c5cdc feat: implement extensive test case
jakehwll0750f37 fix: convert to using dummy values
jakehwll1f0ced1 chore: remove duplicate testcase
jakehwllc536b4b chore: update wording to `Conflicts with subdomain.`
jakehwllFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletiondocs/resources/app.md
This file contains hidden or 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
5 changes: 3 additions & 2 deletionsprovider/app.go
This file contains hidden or 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 |
|---|---|---|
| @@ -85,8 +85,9 @@ func appResource() *schema.Resource { | ||
| Type: schema.TypeString, | ||
| Description: "A command to run in a terminal opening this app. In the web, " + | ||
| "this will open in a new tab. In the CLI, this will SSH and execute the command. " + | ||
| "Either `command` or `url` may be specified, but not both. " + | ||
| "Conflicts with `subdomain`.", | ||
| ConflictsWith: []string{"url", "subdomain"}, | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Optional: true, | ||
| ForceNew: true, | ||
| }, | ||
150 changes: 129 additions & 21 deletionsprovider/app_test.go
This file contains hidden or 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 |
|---|---|---|
| @@ -109,25 +109,6 @@ func TestApp(t *testing.T) { | ||
| } | ||
| `, | ||
| external: true, | ||
| }} | ||
| for _, tc := range cases { | ||
| tc := tc | ||
| @@ -564,8 +545,6 @@ func TestApp(t *testing.T) { | ||
| } | ||
| for _, c := range cases { | ||
| t.Run(c.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| @@ -596,4 +575,133 @@ func TestApp(t *testing.T) { | ||
| }) | ||
| } | ||
| }) | ||
| t.Run("ConflictsWith", func(t *testing.T) { | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| t.Parallel() | ||
| type healthcheck struct { | ||
| url string | ||
| interval int | ||
| threshold int | ||
| } | ||
| dummyURL := "https://google.com" | ||
| dummyCommand := "read -p \\\"Workspace spawned. Press enter to continue...\\\"" | ||
| dummyExternal := true | ||
| dummySubdomain := true | ||
| dummyHealthcheck := healthcheck{ | ||
| url: "https://google.com", | ||
| interval: 5, | ||
| threshold: 6, | ||
| } | ||
| dummyShare := "owner" | ||
| cases := []struct { | ||
| name string | ||
| url string | ||
| command string | ||
| subdomain bool | ||
| healthcheck healthcheck | ||
| external bool | ||
| share string | ||
| expectError *regexp.Regexp | ||
| }{ | ||
| { | ||
| name: "CommandAndSubdomain", | ||
| command: dummyCommand, | ||
| subdomain: dummySubdomain, | ||
| expectError: regexp.MustCompile("conflicts with subdomain"), | ||
| }, | ||
| { | ||
| name: "URLAndCommand", | ||
| url: dummyURL, | ||
| command: dummyCommand, | ||
| expectError: regexp.MustCompile("conflicts with command"), | ||
| }, | ||
| { | ||
| name: "HealthcheckAndCommand", | ||
| healthcheck: dummyHealthcheck, | ||
| command: dummyCommand, | ||
| expectError: regexp.MustCompile("conflicts with command"), | ||
| }, | ||
| { | ||
| name: "ExternalAndHealthcheck", | ||
| external: dummyExternal, | ||
| healthcheck: dummyHealthcheck, | ||
| expectError: regexp.MustCompile("conflicts with healthcheck"), | ||
| }, | ||
| { | ||
| name: "ExternalAndCommand", | ||
| external: dummyExternal, | ||
| command: dummyCommand, | ||
| expectError: regexp.MustCompile("conflicts with command"), | ||
| }, | ||
| { | ||
| name: "ExternalAndSubdomain", | ||
| external: dummyExternal, | ||
| subdomain: dummySubdomain, | ||
| expectError: regexp.MustCompile("conflicts with subdomain"), | ||
| }, | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| { | ||
| name: "ExternalAndShare", | ||
| external: dummyExternal, | ||
| share: dummyShare, | ||
| expectError: regexp.MustCompile("conflicts with share"), | ||
| }, | ||
| } | ||
| for _, c := range cases { | ||
| t.Run(c.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| extraLines := []string{} | ||
| if c.command != "" { | ||
| extraLines = append(extraLines, fmt.Sprintf("command = %q", c.command)) | ||
| } | ||
| if c.subdomain { | ||
| extraLines = append(extraLines, "subdomain = true") | ||
| } | ||
| if c.external { | ||
| extraLines = append(extraLines, "external = true") | ||
| } | ||
| if c.url != "" { | ||
| extraLines = append(extraLines, fmt.Sprintf("url = %q", c.url)) | ||
| } | ||
| if c.healthcheck != (healthcheck{}) { | ||
| extraLines = append(extraLines, fmt.Sprintf(`healthcheck { | ||
| url = %q | ||
| interval = %d | ||
| threshold = %d | ||
| }`, c.healthcheck.url, c.healthcheck.interval, c.healthcheck.threshold)) | ||
| } | ||
| if c.share != "" { | ||
| extraLines = append(extraLines, fmt.Sprintf("share = %q", c.share)) | ||
| } | ||
| config := fmt.Sprintf(` | ||
| provider "coder" {} | ||
| resource "coder_agent" "dev" { | ||
| os = "linux" | ||
| arch = "amd64" | ||
| } | ||
| resource "coder_app" "code-server" { | ||
| agent_id = coder_agent.dev.id | ||
| slug = "code-server" | ||
| display_name = "Testing" | ||
| open_in = "slim-window" | ||
| %s | ||
| } | ||
| `, strings.Join(extraLines, "\n")) | ||
| resource.Test(t, resource.TestCase{ | ||
| ProviderFactories: coderFactory(), | ||
| IsUnitTest: true, | ||
| Steps: []resource.TestStep{{ | ||
| Config: config, | ||
| ExpectError: c.expectError, | ||
| }}, | ||
| }) | ||
| }) | ||
| } | ||
| }) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.