diff options
Diffstat (limited to 'vendor/github.com/mitchellh/packer/builder/oracle/oci/client/client_test.go')
-rw-r--r-- | vendor/github.com/mitchellh/packer/builder/oracle/oci/client/client_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/packer/builder/oracle/oci/client/client_test.go b/vendor/github.com/mitchellh/packer/builder/oracle/oci/client/client_test.go new file mode 100644 index 00000000..f2ebd8f8 --- /dev/null +++ b/vendor/github.com/mitchellh/packer/builder/oracle/oci/client/client_test.go @@ -0,0 +1,49 @@ +package oci + +import ( + "net/http" + "net/http/httptest" + "net/url" + "os" + + "github.com/go-ini/ini" +) + +var ( + mux *http.ServeMux + client *Client + server *httptest.Server + keyFile *os.File +) + +// setup sets up a test HTTP server along with a oci.Client that is +// configured to talk to that test server. Tests should register handlers on +// mux which provide mock responses for the API method being tested. +func setup() { + mux = http.NewServeMux() + server = httptest.NewServer(mux) + parsedURL, _ := url.Parse(server.URL) + + config := &Config{} + config.baseURL = parsedURL.String() + + var cfg *ini.File + var err error + cfg, keyFile, err = BaseTestConfig() + + config, err = loadConfigSection(cfg, "DEFAULT", config) + if err != nil { + panic(err) + } + + client, err = NewClient(config) + if err != nil { + panic("Failed to instantiate test client") + } +} + +// teardown closes the test HTTP server +func teardown() { + server.Close() + os.Remove(keyFile.Name()) +} |