Skip to content

Commit 1a3de0f

Browse files
authored
chore: Removed some unncessary null checks from 'test.go' (microcks#131)
* chore: removed some unncessary null checks from 'test.go' Signed-off-by: Harsh4902 <harshparmar4902@gmail.com> * chore: more clean up tasks Signed-off-by: Harsh4902 <harshparmar4902@gmail.com> --------- Signed-off-by: Harsh4902 <harshparmar4902@gmail.com>
1 parent 704a96d commit 1a3de0f

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

cmd/importURL.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewImportURLCommand() *cobra.Command {
4747
os.Exit(1)
4848
}
4949

50-
specificationFiles := os.Args[2]
50+
specificationFiles := args[0]
5151

5252
// Collect optional HTTPS transport flags.
5353
if insecureTLS {

cmd/test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ import (
2828
)
2929

3030
var (
31-
runnerChoices = map[string]bool{"HTTP": true, "SOAP_HTTP": true, "SOAP_UI": true, "POSTMAN": true, "OPEN_API_SCHEMA": true, "ASYNC_API_SCHEMA": true, "GRPC_PROTOBUF": true, "GRAPHQL_SCHEMA": true}
32-
timeUnitChoices = map[string]bool{"milli": true, "sec": true, "min": true}
31+
runnerChoices = map[string]bool{"HTTP": true, "SOAP_HTTP": true, "SOAP_UI": true, "POSTMAN": true, "OPEN_API_SCHEMA": true, "ASYNC_API_SCHEMA": true, "GRPC_PROTOBUF": true, "GRAPHQL_SCHEMA": true}
3332
)
3433

3534
func NewTestCommand() *cobra.Command {
@@ -58,20 +57,20 @@ func NewTestCommand() *cobra.Command {
5857
os.Exit(1)
5958
}
6059

61-
serviceRef := os.Args[2]
62-
testEndpoint := os.Args[3]
63-
runnerType := os.Args[4]
60+
serviceRef := args[0]
61+
testEndpoint := args[1]
62+
runnerType := args[2]
6463

6564
// Validate presence and values of args.
66-
if &serviceRef == nil || strings.HasPrefix(serviceRef, "-") {
65+
if len(serviceRef) == 0 || strings.HasPrefix(serviceRef, "-") {
6766
fmt.Println("test command require <apiName:apiVersion> <testEndpoint> <runner> args")
6867
os.Exit(1)
6968
}
70-
if &testEndpoint == nil || strings.HasPrefix(testEndpoint, "-") {
69+
if len(testEndpoint) == 0 || strings.HasPrefix(testEndpoint, "-") {
7170
fmt.Println("test command require <apiName:apiVersion> <testEndpoint> <runner> args")
7271
os.Exit(1)
7372
}
74-
if &runnerType == nil || strings.HasPrefix(runnerType, "-") {
73+
if len(runnerType) == 0 || strings.HasPrefix(runnerType, "-") {
7574
fmt.Println("test command require <apiName:apiVersion> <testEndpoint> <runner> args")
7675
os.Exit(1)
7776
}
@@ -81,9 +80,8 @@ func NewTestCommand() *cobra.Command {
8180
}
8281

8382
// Validate presence and values of flags.
84-
if &waitFor == nil || (!strings.HasSuffix(waitFor, "milli") && !strings.HasSuffix(waitFor, "sec") && !strings.HasSuffix(waitFor, "min")) {
83+
if !strings.HasSuffix(waitFor, "milli") && !strings.HasSuffix(waitFor, "sec") && !strings.HasSuffix(waitFor, "min") {
8584
fmt.Println("--waitFor format is wrong. Applying default 5sec")
86-
waitFor = "5sec"
8785
}
8886

8987
// Collect optional HTTPS transport flags.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/microcks/microcks-cli
22

33
go 1.12
44

5-
require github.com/spf13/cobra v1.9.1 // indirect
5+
require github.com/spf13/cobra v1.9.1

0 commit comments

Comments
 (0)