This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝🛠🔀Decoupling functionality to make unit testing easier in the future (…
…#13) * decoupled basic http methods from cli io passing output up to the caller to print to the screen. this will allow easier testing in the future. * uber-go/multierr dependency * decoupled send.go funcs from cli io, cleaned up request() * single location for http.Client this will allow things like timeouts to be configured by the user later * formatting mostly * combined basic post|put|patch|delete into a single function * basic test for getHTTPClient * 📝Updated Readme and ran go mod tidy Co-authored-by: Athul Cyriac Ajay <athul8720@gmail.com>
- Loading branch information
Showing
13 changed files
with
190 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package methods | ||
|
||
import ( | ||
"net/http" | ||
"time" | ||
) | ||
|
||
// The HTTP client can be modified via params and cli flags later | ||
func getHTTPClient() *http.Client { | ||
return &http.Client{ | ||
Timeout: 10 * time.Second, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package methods | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func Test_getHTTPClient(t *testing.T) { | ||
t.Run("default http client", func(t *testing.T) { | ||
client := getHTTPClient() | ||
if client == nil { | ||
t.Error("got nil http client") | ||
} | ||
dur := 10 * time.Second | ||
if client.Timeout != dur { | ||
t.Errorf("timeout doesn't match what's expected: %v", client.Timeout) | ||
} | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.