@@ -339,6 +339,7 @@ func TestTemplatePush(t *testing.T) {
339
339
inv , root := clitest .New (t , "templates" , "push" ,
340
340
"--test.provisioner" , string (database .ProvisionerTypeEcho ),
341
341
"--test.workdir" , source ,
342
+ "--force-tty" ,
342
343
)
343
344
clitest .SetupConfig (t , templateAdmin , root )
344
345
pty := ptytest .New (t ).Attach (inv )
@@ -1075,6 +1076,45 @@ func TestTemplatePush(t *testing.T) {
1075
1076
require .Equal (t , templateName , template .Name )
1076
1077
require .NotEqual (t , uuid .Nil , template .ActiveVersionID )
1077
1078
})
1079
+
1080
+ t .Run ("NoStdinWithCurrentDirectory" , func (t * testing.T ) {
1081
+ t .Parallel ()
1082
+ client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerDaemon : true })
1083
+ owner := coderdtest .CreateFirstUser (t , client )
1084
+ templateAdmin , _ := coderdtest .CreateAnotherUser (t , client , owner .OrganizationID , rbac .RoleTemplateAdmin ())
1085
+ version := coderdtest .CreateTemplateVersion (t , client , owner .OrganizationID , nil )
1086
+ _ = coderdtest .AwaitTemplateVersionJobCompleted (t , client , version .ID )
1087
+
1088
+ template := coderdtest .CreateTemplate (t , client , owner .OrganizationID , version .ID )
1089
+
1090
+ source := clitest .CreateTemplateVersionSource (t , & echo.Responses {
1091
+ Parse : echo .ParseComplete ,
1092
+ ProvisionApply : echo .ApplyComplete ,
1093
+ })
1094
+
1095
+ inv , root := clitest .New (t , "templates" , "push" , template .Name ,
1096
+ "--directory" , "." ,
1097
+ "--test.provisioner" , string (database .ProvisionerTypeEcho ),
1098
+ "--test.workdir" , source ,
1099
+ "--name" , "example" ,
1100
+ "--yes" )
1101
+ clitest .SetupConfig (t , templateAdmin , root )
1102
+
1103
+ inv .Stdin = strings .NewReader ("invalid tar content that would cause failure" )
1104
+
1105
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitMedium )
1106
+ defer cancel ()
1107
+
1108
+ err := inv .WithContext (ctx ).Run ()
1109
+ require .NoError (t , err , "Should succeed without reading from stdin" )
1110
+
1111
+ templateVersions , err := client .TemplateVersionsByTemplate (ctx , codersdk.TemplateVersionsByTemplateRequest {
1112
+ TemplateID : template .ID ,
1113
+ })
1114
+ require .NoError (t , err )
1115
+ require .Len (t , templateVersions , 2 )
1116
+ require .Equal (t , "example" , templateVersions [1 ].Name )
1117
+ })
1078
1118
})
1079
1119
}
1080
1120
0 commit comments