Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit76bda72

Browse files
authored
feat: add confliction withsubdomain (#469)
* feat: add confliction with `subdomain`* fix: provide correct error* feat: implement testing suite* chore: remove unnecessary test suite* fix: resolve `app.md` lint* chore: resolve `app.go` description* Revert "chore: remove unnecessary test suite"This reverts commit3d63e36.* chore: remove unused comments* chore: rename `Command` to `ConflictsWith`* feat: implement extensive test case* fix: convert to using dummy values* chore: remove duplicate testcase* chore: update wording to `Conflicts with subdomain.`
1 parentaee79c4 commit76bda72

File tree

3 files changed

+133
-24
lines changed

3 files changed

+133
-24
lines changed

‎docs/resources/app.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ resource "coder_app" "vim" {
6161

6262
###Optional
6363

64-
-`command` (String) 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.
64+
-`command` (String) 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`.
6565
-`display_name` (String) A display name to identify the app. Defaults to the slug.
6666
-`external` (Boolean) Specifies whether`url` is opened on the client machine instead of proxied through the workspace.
6767
-`group` (String) The name of a group that this app belongs to.

‎provider/app.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ func appResource() *schema.Resource {
8585
Type:schema.TypeString,
8686
Description:"A command to run in a terminal opening this app. In the web, "+
8787
"this will open in a new tab. In the CLI, this will SSH and execute the command. "+
88-
"Either `command` or `url` may be specified, but not both.",
89-
ConflictsWith: []string{"url"},
88+
"Either `command` or `url` may be specified, but not both. "+
89+
"Conflicts with `subdomain`.",
90+
ConflictsWith: []string{"url","subdomain"},
9091
Optional:true,
9192
ForceNew:true,
9293
},

‎provider/app_test.go‎

Lines changed: 129 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,6 @@ func TestApp(t *testing.T) {
109109
}
110110
`,
111111
external:true,
112-
}, {
113-
name:"ConflictsWithSubdomain",
114-
config:`
115-
provider "coder" {}
116-
resource "coder_agent" "dev" {
117-
os = "linux"
118-
arch = "amd64"
119-
}
120-
resource "coder_app" "test" {
121-
agent_id = coder_agent.dev.id
122-
slug = "test"
123-
display_name = "Testing"
124-
url = "https://google.com"
125-
external = true
126-
subdomain = true
127-
open_in = "slim-window"
128-
}
129-
`,
130-
expectError:regexp.MustCompile("conflicts with subdomain"),
131112
}}
132113
for_,tc:=rangecases {
133114
tc:=tc
@@ -564,8 +545,6 @@ func TestApp(t *testing.T) {
564545
}
565546

566547
for_,c:=rangecases {
567-
c:=c
568-
569548
t.Run(c.name,func(t*testing.T) {
570549
t.Parallel()
571550

@@ -596,4 +575,133 @@ func TestApp(t *testing.T) {
596575
})
597576
}
598577
})
578+
579+
t.Run("ConflictsWith",func(t*testing.T) {
580+
t.Parallel()
581+
582+
typehealthcheckstruct {
583+
urlstring
584+
intervalint
585+
thresholdint
586+
}
587+
588+
dummyURL:="https://google.com"
589+
dummyCommand:="read -p\\\"Workspace spawned. Press enter to continue...\\\""
590+
dummyExternal:=true
591+
dummySubdomain:=true
592+
dummyHealthcheck:=healthcheck{
593+
url:"https://google.com",
594+
interval:5,
595+
threshold:6,
596+
}
597+
dummyShare:="owner"
598+
599+
cases:= []struct {
600+
namestring
601+
urlstring
602+
commandstring
603+
subdomainbool
604+
healthcheckhealthcheck
605+
externalbool
606+
sharestring
607+
expectError*regexp.Regexp
608+
}{
609+
{
610+
name:"CommandAndSubdomain",
611+
command:dummyCommand,
612+
subdomain:dummySubdomain,
613+
expectError:regexp.MustCompile("conflicts with subdomain"),
614+
},
615+
{
616+
name:"URLAndCommand",
617+
url:dummyURL,
618+
command:dummyCommand,
619+
expectError:regexp.MustCompile("conflicts with command"),
620+
},
621+
{
622+
name:"HealthcheckAndCommand",
623+
healthcheck:dummyHealthcheck,
624+
command:dummyCommand,
625+
expectError:regexp.MustCompile("conflicts with command"),
626+
},
627+
{
628+
name:"ExternalAndHealthcheck",
629+
external:dummyExternal,
630+
healthcheck:dummyHealthcheck,
631+
expectError:regexp.MustCompile("conflicts with healthcheck"),
632+
},
633+
{
634+
name:"ExternalAndCommand",
635+
external:dummyExternal,
636+
command:dummyCommand,
637+
expectError:regexp.MustCompile("conflicts with command"),
638+
},
639+
{
640+
name:"ExternalAndSubdomain",
641+
external:dummyExternal,
642+
subdomain:dummySubdomain,
643+
expectError:regexp.MustCompile("conflicts with subdomain"),
644+
},
645+
{
646+
name:"ExternalAndShare",
647+
external:dummyExternal,
648+
share:dummyShare,
649+
expectError:regexp.MustCompile("conflicts with share"),
650+
},
651+
}
652+
653+
for_,c:=rangecases {
654+
t.Run(c.name,func(t*testing.T) {
655+
t.Parallel()
656+
657+
extraLines:= []string{}
658+
ifc.command!="" {
659+
extraLines=append(extraLines,fmt.Sprintf("command = %q",c.command))
660+
}
661+
ifc.subdomain {
662+
extraLines=append(extraLines,"subdomain = true")
663+
}
664+
ifc.external {
665+
extraLines=append(extraLines,"external = true")
666+
}
667+
ifc.url!="" {
668+
extraLines=append(extraLines,fmt.Sprintf("url = %q",c.url))
669+
}
670+
ifc.healthcheck!= (healthcheck{}) {
671+
extraLines=append(extraLines,fmt.Sprintf(`healthcheck {
672+
url = %q
673+
interval = %d
674+
threshold = %d
675+
}`,c.healthcheck.url,c.healthcheck.interval,c.healthcheck.threshold))
676+
}
677+
ifc.share!="" {
678+
extraLines=append(extraLines,fmt.Sprintf("share = %q",c.share))
679+
}
680+
681+
config:=fmt.Sprintf(`
682+
provider "coder" {}
683+
resource "coder_agent" "dev" {
684+
os = "linux"
685+
arch = "amd64"
686+
}
687+
resource "coder_app" "code-server" {
688+
agent_id = coder_agent.dev.id
689+
slug = "code-server"
690+
display_name = "Testing"
691+
open_in = "slim-window"
692+
%s
693+
}
694+
`,strings.Join(extraLines,"\n"))
695+
696+
resource.Test(t, resource.TestCase{
697+
ProviderFactories:coderFactory(),
698+
IsUnitTest:true,
699+
Steps: []resource.TestStep{{
700+
Config:config,
701+
ExpectError:c.expectError,
702+
}},
703+
})
704+
})
705+
}
706+
})
599707
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp