21
21
package client
22
22
23
23
import (
24
+ "fmt"
24
25
"io/ioutil"
25
26
"net/http"
26
27
"testing"
@@ -40,12 +41,12 @@ func TestComposeTypesV0(t *testing.T) {
40
41
require .Greater (t , len (composeTypes ), 0 )
41
42
var found bool
42
43
for _ , t := range composeTypes {
43
- if t .Name == "qcow2" && t .Enabled == true {
44
+ if t .Name == testState . imageTypeName && t .Enabled == true {
44
45
found = true
45
46
break
46
47
}
47
48
}
48
- require .True (t , found , "qcow2 not in list of compose types: %#v" , composeTypes )
49
+ require .True (t , found , "%s not in list of compose types: %#v" , testState . imageTypeName , composeTypes )
49
50
}
50
51
51
52
// Test compose with invalid type fails
@@ -76,11 +77,11 @@ func TestComposeInvalidTypeV0(t *testing.T) {
76
77
77
78
// Test compose for unknown blueprint fails
78
79
func TestComposeInvalidBlueprintV0 (t * testing.T ) {
79
- compose := `{
80
+ compose := fmt . Sprintf ( `{
80
81
"blueprint_name": "test-invalid-bp-compose-v0",
81
- "compose_type": "qcow2 ",
82
+ "compose_type": "%s ",
82
83
"branch": "master"
83
- }`
84
+ }` , testState . imageTypeName )
84
85
resp , err := PostComposeV0 (testState .socket , compose )
85
86
require .NoError (t , err , "failed with a client error" )
86
87
require .NotNil (t , resp )
@@ -91,11 +92,11 @@ func TestComposeInvalidBlueprintV0(t *testing.T) {
91
92
92
93
// Test compose for empty blueprint fails
93
94
func TestComposeEmptyBlueprintV0 (t * testing.T ) {
94
- compose := `{
95
+ compose := fmt . Sprintf ( `{
95
96
"blueprint_name": "",
96
- "compose_type": "qcow2 ",
97
+ "compose_type": "%s ",
97
98
"branch": "master"
98
- }`
99
+ }` , testState . imageTypeName )
99
100
resp , err := PostComposeV0 (testState .socket , compose )
100
101
require .NoError (t , err , "failed with a client error" )
101
102
require .NotNil (t , resp )
@@ -106,11 +107,11 @@ func TestComposeEmptyBlueprintV0(t *testing.T) {
106
107
107
108
// Test compose for blueprint with invalid characters fails
108
109
func TestComposeInvalidCharsBlueprintV0 (t * testing.T ) {
109
- compose := `{
110
+ compose := fmt . Sprintf ( `{
110
111
"blueprint_name": "I w𝒊ll 𝟉ο𝘁 𝛠a𝔰ꜱ 𝘁𝒉𝝸𝚜",
111
- "compose_type": "qcow2 ",
112
+ "compose_type": "%s ",
112
113
"branch": "master"
113
- }`
114
+ }` , testState . imageTypeName )
114
115
resp , err := PostComposeV0 (testState .socket , compose )
115
116
require .NoError (t , err , "failed with a client error" )
116
117
require .NotNil (t , resp )
@@ -283,11 +284,11 @@ func TestFailedComposeV0(t *testing.T) {
283
284
require .NoError (t , err , "failed with a client error" )
284
285
require .True (t , resp .Status , "POST failed: %#v" , resp )
285
286
286
- compose := `{
287
+ compose := fmt . Sprintf ( `{
287
288
"blueprint_name": "test-failed-compose-v0",
288
- "compose_type": "qcow2 ",
289
+ "compose_type": "%s ",
289
290
"branch": "master"
290
- }`
291
+ }` , testState . imageTypeName )
291
292
// Create a failed test compose
292
293
body , resp , err := PostJSON (testState .socket , "/api/v1/compose?test=1" , compose )
293
294
require .NoError (t , err , "failed with a client error" )
@@ -378,11 +379,11 @@ func TestFinishedComposeV0(t *testing.T) {
378
379
require .NoError (t , err , "failed with a client error" )
379
380
require .True (t , resp .Status , "POST failed: %#v" , resp )
380
381
381
- compose := `{
382
+ compose := fmt . Sprintf ( `{
382
383
"blueprint_name": "test-finished-compose-v0",
383
- "compose_type": "qcow2 ",
384
+ "compose_type": "%s ",
384
385
"branch": "master"
385
- }`
386
+ }` , testState . imageTypeName )
386
387
// Create a finished test compose
387
388
body , resp , err := PostJSON (testState .socket , "/api/v1/compose?test=2" , compose )
388
389
require .NoError (t , err , "failed with a client error" )
0 commit comments