Skip to content

Commit 2072219

Browse files
committed
some tidy, unit test for non-dependent functions implemented
1 parent f2cfa22 commit 2072219

File tree

8 files changed

+52
-69
lines changed

8 files changed

+52
-69
lines changed

.azuredevops/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

.azuredevops/pull_request_template/branches/dev.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

.azuredevops/pull_request_template/branches/terraform.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

httpclient/config_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131

3232
// LoadConfigFromFile loads http client configuration settings from a JSON file.
3333
func LoadConfigFromFile(filepath string) (*ClientConfig, error) {
34-
absPath, err := validateFilePath(filepath)
34+
absPath, err := validateConfigFilePath(filepath)
3535
if err != nil {
3636
return nil, fmt.Errorf("invalid file path: %v", err)
3737
}

httpclient/methods_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// httpmethod/httpmethod.go
2+
package httpclient
3+
4+
import (
5+
"net/http"
6+
"testing"
7+
)
8+
9+
func Test_isIdempotentHTTPMethod(t *testing.T) {
10+
type args struct {
11+
method string
12+
}
13+
tests := []struct {
14+
name string
15+
args args
16+
want bool
17+
}{
18+
{
19+
name: "testing an indempotent method",
20+
args: args{
21+
method: http.MethodGet,
22+
},
23+
want: true,
24+
},
25+
{
26+
name: "testing a nonindempotent method",
27+
args: args{
28+
method: http.MethodPost,
29+
},
30+
want: false,
31+
},
32+
}
33+
for _, tt := range tests {
34+
t.Run(tt.name, func(t *testing.T) {
35+
if got := isIdempotentHTTPMethod(tt.args.method); got != tt.want {
36+
t.Errorf("isIdempotentHTTPMethod() = %v, want %v", got, tt.want)
37+
}
38+
})
39+
}
40+
}

httpclient/testing_helpers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package httpclient
2+
3+
import "go.uber.org/zap"
4+
5+
func standardSugaredLogger() *zap.SugaredLogger {
6+
logger, _ := zap.NewProduction()
7+
return logger.Sugar()
8+
}

httpclient/utility.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
const ConfigFileExtension = ".json"
1717

1818
// validateFilePath checks if a file path is valid.
19-
func validateFilePath(path string) (string, error) {
19+
func validateConfigFilePath(path string) (string, error) {
2020
cleanPath := filepath.Clean(path)
2121

2222
absPath, err := filepath.EvalSymlinks(cleanPath)

httpclient/utility_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// httpclient/utility.go
2+
package httpclient

0 commit comments

Comments
 (0)