From 662db3ca9e810f60f83467eed9ad9794b523aa9d Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 9 Feb 2024 17:15:15 +0100 Subject: [PATCH] Test cache list key is sent to API --- pkg/cmd/cache/list/list_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/cmd/cache/list/list_test.go b/pkg/cmd/cache/list/list_test.go index 30c248c22..0c31f42eb 100644 --- a/pkg/cmd/cache/list/list_test.go +++ b/pkg/cmd/cache/list/list_test.go @@ -186,6 +186,26 @@ ID KEY SIZE CREATED ACCESSED }, wantStdout: "1\tfoo\t100 B\t2021-01-01T01:01:01Z\t2022-01-01T01:01:01Z\n2\tbar\t1.00 KiB\t2021-01-01T01:01:01Z\t2022-01-01T01:01:01Z\n", }, + { + name: "only requests caches with the provided key prefix", + opts: ListOptions{ + Key: "test-key", + }, + stubs: func(reg *httpmock.Registry) { + reg.Register( + func(req *http.Request) bool { + return req.URL.Query().Get("key") == "test-key" + }, + httpmock.JSONResponse(shared.CachePayload{ + ActionsCaches: []shared.Cache{}, + TotalCount: 0, + })) + }, + // We could put anything here, we're really asserting that the key is passed + // to the API. + wantErr: true, + wantErrMsg: "No caches found in OWNER/REPO", + }, { name: "displays no results", stubs: func(reg *httpmock.Registry) {