Skip to content

Commit 1eb906b

Browse files
committed
Address pull request comments
1 parent 04669ad commit 1eb906b

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ main
1818
# Files used for debugging
1919
.vscode/
2020

21+
# File created running tests
22+
tests/src/tests/tmp/
23+
2124
.DS_Store

tests/src/tests/README.md

+25-21
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The tests use the go language and are intended to test every apsect of the parse
1010
* Parser functions covered:
1111
* Read an existing devfile.
1212
* Write a new devfile.
13-
* Modify Content of a devfile.
13+
* Modify content of a devfile.
1414
* Multi-threaded access to the parser.
1515
* The tests use the devfile schema to create a structure containing expected content for a devfile. These structures are compared with those returned by the parser.
1616
* sigs.k8s.io/yaml is used to write out devfiles.
@@ -87,6 +87,10 @@ There are also some constants which control execution of the tests:
8787

8888
* Each devfile is created in a schema structure.
8989
* Which attributes are set and the values used are randomized.
90+
* For example, the number of commands included in a devfile is randomly generated.
91+
* For example, attribute values are set to randomized strings, numbers or binary.
92+
* For example, a particular optional attribute has a 50% chance of being uncluded in a devfiles.
93+
* Repeated tests give more variety and wider coverage.
9094
* Once the schema structure is complete it is written in one of two ways.
9195
* using the sigs.k8s.io/yaml.
9296
* using the parser.
@@ -124,10 +128,10 @@ For example add support for apply command to existing command support:
124128

125129
1. In ```command-test-utils.go```
126130
* add functions:
127-
* ```func createApplyCommand() *schema.ApplyCommand```
128-
* creates the apply command object and calls setApplyCommandValues to add attribute values
129131
* ```func setApplyCommandValues(applyCommand *schema.ApplyCommand)```
130132
* randomly set attribute values in the provided apply command object
133+
* ```func createApplyCommand() *schema.ApplyCommand```
134+
* creates the apply command object and calls setApplyCommandValues to add attribute values
131135
* follow the implementation of other similar functions.
132136
* modify:
133137
* ```func generateCommand(command *schema.Command, genericCommand *GenericCommand)```
@@ -164,33 +168,33 @@ Using existing support for commands as an illustration, any new property support
164168
* sets random attributes into the provided object
165169
* for example see: ```func setExecCommandValues(execCommand *schema.ExecCommand)```
166170
* Functions general to all commands
171+
* ```func generateCommand(command *schema.Command, genericCommand *GenericCommand)```
172+
* includes logic to call the ```create<Command-Type>Command``` function for the command-Type of the supplied command object.
167173
* ```func (devfile *TestDevfile) addCommand(commandType schema.CommandType) string```
168174
* main entry point for a test to add a command
169175
* maintains the array of commands in the schema structure
170176
* calls generateCommand()
171-
* ```func generateCommand(command *schema.Command, genericCommand *GenericCommand)```
172-
* includes logic to call the ```create<Command-Type>Command``` function for the command-Type of the supplied command object.
173177
* ```func (devfile *TestDevfile) UpdateCommand(command *schema.Command) error```
174178
* includes logic to call set<commad-type>CommandValues for each commandType.
175179
* ```func (devfile TestDevfile) VerifyCommands(parserCommands []schema.Command) error```
176-
* Includes logic to compare the array of commands obtained from the parser with those created by the test. if the compare fails:
180+
* includes logic to compare the array of commands obtained from the parser with those created by the test. if the compare fails:
177181
* each individual command is compared.
178182
* if a command compare fails, the parser version and test version of the command are oputput as yaml files to the tmp directory
179183
* a check is made to determine if the parser returned a command not known to the test or the pasrer omitted a command expected by the test.
180184
1. ```test-utils.go```
181185
* ```func (devfile TestDevfile) Verify()```
182-
* Includes code to get object from the paser and verify their content.
183-
* For commands code is required to:
186+
* includes code to get object from the paser and verify their content.
187+
* for commands code is required to:
184188
1. Retrieve each command from the parser
185-
1. Use command id to obtain the GenericCommand object which matches
186-
1. compare the command structure returned by the parser with the command structure saved in the GenericCommand object.
189+
1. Use command Id to obtain the GenericCommand object which matches
190+
1. Compare the command structure returned by the parser with the command structure saved in the GenericCommand object.
187191
* ```func (devfile TestDevfile) EditCommands() error```
188-
* Specific to command objects.
192+
* specific to command objects.
189193
1. Ensure devfile is written to disk
190-
1. use parser to read devfile and get all command object
191-
1. for each command call:
194+
1. Use parser to read devfile and get all command object
195+
1. For each command call:
192196
* ```func (devfile *TestDevfile) UpdateCommand(command *schema.Command) error```
193-
1. when all commands have been updated, use parser to write the updated devfile to disk
197+
1. When all commands have been updated, use parser to write the updated devfile to disk
194198
1. ```parser-v200-test.go```
195199
* ```type TestContent struct```
196200
* includes an array of command types: ```CommandTypes []schema.CommandType```
@@ -200,12 +204,12 @@ Using existing support for commands as an illustration, any new property support
200204
1. Calls runTest for a single thread test
201205
1. Calls runMultiThreadTest for a multi-thread test.
202206
* See also
203-
*```func Test_<string>ExecCommand(t *testing.T)```
204-
*```func Test_MultiCommand(t *testing.T)```
205-
*```func Test_Everything(t *testing.T)```
206-
* add logic to ```func runTest(testContent TestContent, t *testing.T)``` includes logic
207-
1. Add commands to the test
208-
2. Starts edits of commands if required.
207+
* ```func Test_<string>ExecCommand(t *testing.T)```
208+
* ```func Test_MultiCommand(t *testing.T)```
209+
* ```func Test_Everything(t *testing.T)```
210+
* Add logic to ```func runTest(testContent TestContent, t *testing.T)```
211+
1. Add commands to the test.
212+
2. Start edits of commands if required.
209213

210214

211215
#### Code flow
@@ -215,7 +219,7 @@ Create, modify and verify an exec command:
215219
1. parser-v200-test.runTest
216220
1. command-test-utils.AddCommand
217221
1. command-test-utils.GenerateCommand
218-
1. command-test-utils.createExecCommand
222+
1. command-test-utils.createExecCommand
219223
1. command-test-utils.setExecCommandValues
220224
1. test-utils.CreateDevfile
221225
1. test-utils.EditCommands

0 commit comments

Comments
 (0)