-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add grype version to db network operations (#2062)
Signed-off-by: Keith Zantow <[email protected]>
- Loading branch information
Showing
5 changed files
with
73 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package commands | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/anchore/clio" | ||
) | ||
|
||
func Test_ListingUserAgent(t *testing.T) { | ||
listingFile := "/listing.json" | ||
|
||
got := "" | ||
|
||
// setup mock | ||
handler := http.NewServeMux() | ||
handler.HandleFunc(listingFile, func(w http.ResponseWriter, r *http.Request) { | ||
got = r.Header.Get("User-Agent") | ||
w.WriteHeader(http.StatusOK) | ||
_, _ = w.Write([]byte("1.0.0")) | ||
}) | ||
mockSrv := httptest.NewServer(handler) | ||
defer mockSrv.Close() | ||
|
||
dbOptions := *dbOptionsDefault(clio.Identification{ | ||
Name: "the-app", | ||
Version: "v3.2.1", | ||
}) | ||
dbOptions.DB.RequireUpdateCheck = true | ||
dbOptions.DB.UpdateURL = mockSrv.URL + listingFile | ||
|
||
_ = runDBList(&dbListOptions{ | ||
Output: "", | ||
DBOptions: dbOptions, | ||
}) | ||
|
||
if got != "the-app v3.2.1" { | ||
t.Errorf("expected User-Agent header to match, got: %v", got) | ||
} | ||
} |
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