Skip to content

Commit

Permalink
Merge pull request #49 from newrelic/mwhelan/testFix
Browse files Browse the repository at this point in the history
Fix unit tests
  • Loading branch information
Matt Whelan authored Feb 22, 2021
2 parents d243e52 + 174031e commit 3f4051e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion checks/runtimeCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ func latestAgentTag(r *runtimeConfig) error {
return err
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
// The version check HTTP request failed; this doesn't tell us anything
util.Debugf("Can't query latest agent version. Request to %v returned status %v", r.agentVersionUrl, resp.StatusCode)
return nil
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
err = json.Unmarshal([]byte(body), &r)
err = json.Unmarshal(body, &r)
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions checks/runtimeCheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ func TestRuntimeCheck(t *testing.T) {
assert.NotEqual(t, dirname, "")
assert.Nil(t, err)

oldPath := runtimeLookupPath;
defer func() {
runtimeLookupPath = oldPath
}()
runtimeLookupPath = fmt.Sprintf("%s/%s", dirname, runtimeLookupPath)

os.MkdirAll(runtimeLookupPath+"/node", os.ModePerm)
defer os.RemoveAll(dirname + "/var")
r, err := checkAndReturnRuntime()
Expand Down

0 comments on commit 3f4051e

Please sign in to comment.