6
6
"path/filepath"
7
7
"testing"
8
8
9
- workspaces "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
9
+ dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
10
10
attributesPkg "github.com/devfile/api/v2/pkg/attributes"
11
11
"github.com/stretchr/testify/assert"
12
12
"k8s.io/apimachinery/pkg/util/json"
@@ -18,135 +18,135 @@ func TestBasicMerging(t *testing.T) {
18
18
19
19
tests := []struct {
20
20
name string
21
- mainContent * workspaces .DevWorkspaceTemplateSpecContent
22
- parentFlattenedContent * workspaces .DevWorkspaceTemplateSpecContent
23
- pluginFlattenedContents []* workspaces .DevWorkspaceTemplateSpecContent
24
- expected * workspaces .DevWorkspaceTemplateSpecContent
21
+ mainContent * dw .DevWorkspaceTemplateSpecContent
22
+ parentFlattenedContent * dw .DevWorkspaceTemplateSpecContent
23
+ pluginFlattenedContents []* dw .DevWorkspaceTemplateSpecContent
24
+ expected * dw .DevWorkspaceTemplateSpecContent
25
25
wantErr * string
26
26
}{
27
27
{
28
28
name : "Basic Merging" ,
29
- mainContent : & workspaces .DevWorkspaceTemplateSpecContent {
29
+ mainContent : & dw .DevWorkspaceTemplateSpecContent {
30
30
Variables : map [string ]string {
31
31
"version1" : "main" ,
32
32
},
33
33
Attributes : attributesPkg.Attributes {}.FromMap (map [string ]interface {}{
34
34
"main" : true ,
35
35
}, nil ),
36
- Commands : []workspaces .Command {
36
+ Commands : []dw .Command {
37
37
{
38
38
Id : "mainCommand" ,
39
- CommandUnion : workspaces .CommandUnion {
40
- Exec : & workspaces .ExecCommand {
39
+ CommandUnion : dw .CommandUnion {
40
+ Exec : & dw .ExecCommand {
41
41
WorkingDir : "dir" ,
42
42
},
43
43
},
44
44
},
45
45
},
46
- Components : []workspaces .Component {
46
+ Components : []dw .Component {
47
47
{
48
48
Name : "mainComponent" ,
49
- ComponentUnion : workspaces .ComponentUnion {
50
- Container : & workspaces .ContainerComponent {
51
- Container : workspaces .Container {
49
+ ComponentUnion : dw .ComponentUnion {
50
+ Container : & dw .ContainerComponent {
51
+ Container : dw .Container {
52
52
Image : "image" ,
53
53
},
54
54
},
55
55
},
56
56
},
57
57
{
58
58
Name : "mainPluginComponent" ,
59
- ComponentUnion : workspaces .ComponentUnion {
60
- Plugin : & workspaces .PluginComponent {
61
- ImportReference : workspaces .ImportReference {
62
- ImportReferenceUnion : workspaces .ImportReferenceUnion {
59
+ ComponentUnion : dw .ComponentUnion {
60
+ Plugin : & dw .PluginComponent {
61
+ ImportReference : dw .ImportReference {
62
+ ImportReferenceUnion : dw .ImportReferenceUnion {
63
63
Uri : "uri" ,
64
64
},
65
65
},
66
66
},
67
67
},
68
68
},
69
69
},
70
- Events : & workspaces .Events {
71
- WorkspaceEvents : workspaces. WorkspaceEvents {
70
+ Events : & dw .Events {
71
+ DevWorkspaceEvents : dw. DevWorkspaceEvents {
72
72
PostStop : []string {"post-stop-main" },
73
73
},
74
74
},
75
75
},
76
- pluginFlattenedContents : []* workspaces .DevWorkspaceTemplateSpecContent {
76
+ pluginFlattenedContents : []* dw .DevWorkspaceTemplateSpecContent {
77
77
{
78
78
Variables : map [string ]string {
79
79
"version2" : "plugin" ,
80
80
},
81
81
Attributes : attributesPkg.Attributes {}.FromMap (map [string ]interface {}{
82
82
"plugin" : true ,
83
83
}, nil ),
84
- Commands : []workspaces .Command {
84
+ Commands : []dw .Command {
85
85
{
86
86
Id : "pluginCommand" ,
87
- CommandUnion : workspaces .CommandUnion {
88
- Exec : & workspaces .ExecCommand {
87
+ CommandUnion : dw .CommandUnion {
88
+ Exec : & dw .ExecCommand {
89
89
WorkingDir : "dir" ,
90
90
},
91
91
},
92
92
},
93
93
},
94
- Components : []workspaces .Component {
94
+ Components : []dw .Component {
95
95
{
96
96
Name : "pluginComponent" ,
97
- ComponentUnion : workspaces .ComponentUnion {
98
- Container : & workspaces .ContainerComponent {
99
- Container : workspaces .Container {
97
+ ComponentUnion : dw .ComponentUnion {
98
+ Container : & dw .ContainerComponent {
99
+ Container : dw .Container {
100
100
Image : "image" ,
101
101
},
102
102
},
103
103
},
104
104
},
105
105
},
106
- Events : & workspaces .Events {
107
- WorkspaceEvents : workspaces. WorkspaceEvents {
106
+ Events : & dw .Events {
107
+ DevWorkspaceEvents : dw. DevWorkspaceEvents {
108
108
PostStop : []string {"post-stop-plugin" },
109
109
},
110
110
},
111
111
},
112
112
},
113
- parentFlattenedContent : & workspaces .DevWorkspaceTemplateSpecContent {
113
+ parentFlattenedContent : & dw .DevWorkspaceTemplateSpecContent {
114
114
Variables : map [string ]string {
115
115
"version3" : "parent" ,
116
116
},
117
117
Attributes : attributesPkg.Attributes {}.FromMap (map [string ]interface {}{
118
118
"parent" : true ,
119
119
}, nil ),
120
- Commands : []workspaces .Command {
120
+ Commands : []dw .Command {
121
121
{
122
122
Id : "parentCommand" ,
123
- CommandUnion : workspaces .CommandUnion {
124
- Exec : & workspaces .ExecCommand {
123
+ CommandUnion : dw .CommandUnion {
124
+ Exec : & dw .ExecCommand {
125
125
WorkingDir : "dir" ,
126
126
},
127
127
},
128
128
},
129
129
},
130
- Components : []workspaces .Component {
130
+ Components : []dw .Component {
131
131
{
132
132
Name : "parentComponent" ,
133
- ComponentUnion : workspaces .ComponentUnion {
134
- Container : & workspaces .ContainerComponent {
135
- Container : workspaces .Container {
133
+ ComponentUnion : dw .ComponentUnion {
134
+ Container : & dw .ContainerComponent {
135
+ Container : dw .Container {
136
136
Image : "image" ,
137
137
},
138
138
},
139
139
},
140
140
},
141
141
},
142
- Events : & workspaces .Events {
143
- WorkspaceEvents : workspaces. WorkspaceEvents {
142
+ Events : & dw .Events {
143
+ DevWorkspaceEvents : dw. DevWorkspaceEvents {
144
144
PostStop : []string {"post-stop-parent" },
145
145
PostStart : []string {"post-start-parent" },
146
146
},
147
147
},
148
148
},
149
- expected : & workspaces .DevWorkspaceTemplateSpecContent {
149
+ expected : & dw .DevWorkspaceTemplateSpecContent {
150
150
Variables : map [string ]string {
151
151
"version3" : "parent" ,
152
152
"version2" : "plugin" ,
@@ -157,66 +157,66 @@ func TestBasicMerging(t *testing.T) {
157
157
"plugin" : true ,
158
158
"main" : true ,
159
159
}, nil ),
160
- Commands : []workspaces .Command {
160
+ Commands : []dw .Command {
161
161
{
162
162
Id : "parentCommand" ,
163
- CommandUnion : workspaces .CommandUnion {
164
- Exec : & workspaces .ExecCommand {
163
+ CommandUnion : dw .CommandUnion {
164
+ Exec : & dw .ExecCommand {
165
165
WorkingDir : "dir" ,
166
166
},
167
167
},
168
168
},
169
169
{
170
170
Id : "pluginCommand" ,
171
- CommandUnion : workspaces .CommandUnion {
172
- Exec : & workspaces .ExecCommand {
171
+ CommandUnion : dw .CommandUnion {
172
+ Exec : & dw .ExecCommand {
173
173
WorkingDir : "dir" ,
174
174
},
175
175
},
176
176
},
177
177
{
178
178
Id : "mainCommand" ,
179
- CommandUnion : workspaces .CommandUnion {
180
- Exec : & workspaces .ExecCommand {
179
+ CommandUnion : dw .CommandUnion {
180
+ Exec : & dw .ExecCommand {
181
181
WorkingDir : "dir" ,
182
182
},
183
183
},
184
184
},
185
185
},
186
- Components : []workspaces .Component {
186
+ Components : []dw .Component {
187
187
{
188
188
Name : "parentComponent" ,
189
- ComponentUnion : workspaces .ComponentUnion {
190
- Container : & workspaces .ContainerComponent {
191
- Container : workspaces .Container {
189
+ ComponentUnion : dw .ComponentUnion {
190
+ Container : & dw .ContainerComponent {
191
+ Container : dw .Container {
192
192
Image : "image" ,
193
193
},
194
194
},
195
195
},
196
196
},
197
197
{
198
198
Name : "pluginComponent" ,
199
- ComponentUnion : workspaces .ComponentUnion {
200
- Container : & workspaces .ContainerComponent {
201
- Container : workspaces .Container {
199
+ ComponentUnion : dw .ComponentUnion {
200
+ Container : & dw .ContainerComponent {
201
+ Container : dw .Container {
202
202
Image : "image" ,
203
203
},
204
204
},
205
205
},
206
206
},
207
207
{
208
208
Name : "mainComponent" ,
209
- ComponentUnion : workspaces .ComponentUnion {
210
- Container : & workspaces .ContainerComponent {
211
- Container : workspaces .Container {
209
+ ComponentUnion : dw .ComponentUnion {
210
+ Container : & dw .ContainerComponent {
211
+ Container : dw .Container {
212
212
Image : "image" ,
213
213
},
214
214
},
215
215
},
216
216
},
217
217
},
218
- Events : & workspaces .Events {
219
- WorkspaceEvents : workspaces. WorkspaceEvents {
218
+ Events : & dw .Events {
219
+ DevWorkspaceEvents : dw. DevWorkspaceEvents {
220
220
PreStart : []string {},
221
221
PostStart : []string {"post-start-parent" },
222
222
PreStop : []string {},
@@ -337,9 +337,9 @@ func TestMergingOnlyPlugins(t *testing.T) {
337
337
pluginFile := "test-fixtures/merges/no-parent/plugin.yaml"
338
338
resultFile := "test-fixtures/merges/no-parent/result.yaml"
339
339
340
- baseDWT := workspaces .DevWorkspaceTemplateSpecContent {}
341
- pluginDWT := workspaces .DevWorkspaceTemplateSpecContent {}
342
- expectedDWT := workspaces .DevWorkspaceTemplateSpecContent {}
340
+ baseDWT := dw .DevWorkspaceTemplateSpecContent {}
341
+ pluginDWT := dw .DevWorkspaceTemplateSpecContent {}
342
+ expectedDWT := dw .DevWorkspaceTemplateSpecContent {}
343
343
344
344
readFileToStruct (t , baseFile , & baseDWT )
345
345
readFileToStruct (t , pluginFile , & pluginDWT )
@@ -357,9 +357,9 @@ func TestMergingOnlyParent(t *testing.T) {
357
357
parentFile := "test-fixtures/merges/no-parent/plugin.yaml"
358
358
resultFile := "test-fixtures/merges/no-parent/result.yaml"
359
359
360
- baseDWT := workspaces .DevWorkspaceTemplateSpecContent {}
361
- parentDWT := workspaces .DevWorkspaceTemplateSpecContent {}
362
- expectedDWT := workspaces .DevWorkspaceTemplateSpecContent {}
360
+ baseDWT := dw .DevWorkspaceTemplateSpecContent {}
361
+ parentDWT := dw .DevWorkspaceTemplateSpecContent {}
362
+ expectedDWT := dw .DevWorkspaceTemplateSpecContent {}
363
363
364
364
readFileToStruct (t , baseFile , & baseDWT )
365
365
readFileToStruct (t , parentFile , & parentDWT )
0 commit comments