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

Commit63c5cdc

Browse files
committed
feat: implement extensive test case
1 parent5c3e18c commit63c5cdc

File tree

1 file changed

+75
-11
lines changed

1 file changed

+75
-11
lines changed

‎provider/app_test.go‎

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,6 @@ func TestApp(t *testing.T) {
564564
}
565565

566566
for_,c:=rangecases {
567-
c:=c
568-
569567
t.Run(c.name,func(t*testing.T) {
570568
t.Parallel()
571569

@@ -600,33 +598,100 @@ func TestApp(t *testing.T) {
600598
t.Run("ConflictsWith",func(t*testing.T) {
601599
t.Parallel()
602600

601+
typehealthcheckstruct {
602+
urlstring
603+
intervalint
604+
thresholdint
605+
}
606+
603607
cases:= []struct {
604608
namestring
609+
urlstring
605610
commandstring
606611
subdomainbool
612+
healthcheckhealthcheck
613+
externalbool
614+
sharestring
607615
expectError*regexp.Regexp
608616
}{
609617
{
610-
name:"Command",
611-
command:"read -p\\\"Workspace spawned. Press enter to continue...\\\"",
618+
name:"CommandAndSubdomain",
619+
command:"read -p\\\"Workspace spawned. Press enter to continue...\\\"",
620+
subdomain:true,
621+
expectError:regexp.MustCompile("conflicts with subdomain"),
612622
},
613623
{
614-
name:"CommandAndURL",
624+
name:"URLAndCommand",
625+
url:"https://google.com",
615626
command:"read -p\\\"Workspace spawned. Press enter to continue...\\\"",
627+
expectError:regexp.MustCompile("conflicts with command"),
628+
},
629+
{
630+
name:"HealthcheckAndCommand",
631+
healthcheck:healthcheck{
632+
url:"https://google.com",
633+
interval:5,
634+
threshold:6,
635+
},
636+
command:"read -p\\\"Workspace spawned. Press enter to continue...\\\"",
637+
expectError:regexp.MustCompile("conflicts with command"),
638+
},
639+
{
640+
name:"ExternalAndHealthcheck",
641+
external:true,
642+
healthcheck:healthcheck{
643+
url:"https://google.com",
644+
interval:5,
645+
threshold:6,
646+
},
647+
expectError:regexp.MustCompile("conflicts with healthcheck"),
648+
},
649+
{
650+
name:"ExternalAndCommand",
651+
external:true,
652+
command:"read -p\\\"Workspace spawned. Press enter to continue...\\\"",
653+
expectError:regexp.MustCompile("conflicts with command"),
654+
},
655+
{
656+
name:"ExternalAndSubdomain",
657+
external:true,
616658
subdomain:true,
617659
expectError:regexp.MustCompile("conflicts with subdomain"),
618660
},
661+
{
662+
name:"ExternalAndShare",
663+
external:true,
664+
share:"https://google.com",
665+
expectError:regexp.MustCompile("conflicts with share"),
666+
},
619667
}
620668

621669
for_,c:=rangecases {
622-
c:=c
623-
624670
t.Run(c.name,func(t*testing.T) {
625671
t.Parallel()
626672

627-
subdomainLine:=""
673+
extraLines:= []string{}
674+
ifc.command!="" {
675+
extraLines=append(extraLines,fmt.Sprintf("command = %q",c.command))
676+
}
628677
ifc.subdomain {
629-
subdomainLine="subdomain = true"
678+
extraLines=append(extraLines,"subdomain = true")
679+
}
680+
ifc.external {
681+
extraLines=append(extraLines,"external = true")
682+
}
683+
ifc.url!="" {
684+
extraLines=append(extraLines,fmt.Sprintf("url = %q",c.url))
685+
}
686+
ifc.healthcheck!= (healthcheck{}) {
687+
extraLines=append(extraLines,fmt.Sprintf(`healthcheck {
688+
url = %q
689+
interval = %d
690+
threshold = %d
691+
}`,c.healthcheck.url,c.healthcheck.interval,c.healthcheck.threshold))
692+
}
693+
ifc.share!="" {
694+
extraLines=append(extraLines,fmt.Sprintf("share = %q",c.share))
630695
}
631696

632697
config:=fmt.Sprintf(`
@@ -640,10 +705,9 @@ func TestApp(t *testing.T) {
640705
slug = "code-server"
641706
display_name = "Testing"
642707
open_in = "slim-window"
643-
command = "%s"
644708
%s
645709
}
646-
`,c.command,subdomainLine)
710+
`,strings.Join(extraLines,"\n"))
647711

648712
resource.Test(t, resource.TestCase{
649713
ProviderFactories:coderFactory(),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp