add resource_history_list test

pull/90170/head
Georges Chaudy 11 months ago
parent f6b32c94bd
commit e8214869de
No known key found for this signature in database
GPG Key ID: 0EE887FFCA1DB6EF
  1. 23
      pkg/storage/unified/sql/queries_test.go
  2. 11
      pkg/storage/unified/sql/testdata/resource_history_list_mysql_sqlite.sql

@ -185,6 +185,29 @@ func TestQueries(t *testing.T) {
},
},
},
sqlResourceHistoryList: {
{
Name: "single path",
Data: &sqlResourceHistoryListRequest{
SQLTemplate: new(sqltemplate.SQLTemplate),
Request: &historyListRequest{
Limit: 10,
Options: &resource.ListOptions{
Key: &resource.ResourceKey{
Namespace: "ns",
},
},
},
Response: new(resource.ResourceWrapper),
},
Expected: expected{
"resource_history_list_mysql_sqlite.sql": dialects{
sqltemplate.MySQL,
sqltemplate.SQLite,
},
},
},
},
sqlResourceUpdateRV: {
{
Name: "single path",

@ -0,0 +1,11 @@
SELECT kv."resource_version", "value"
FROM "resource_history" as kv
JOIN (
SELECT "guid", max("resource_version") AS "resource_version"
FROM "resource_history" AS mkv
WHERE 1 = 1 AND "resource_version" <= ? AND "namespace" = ?
GROUP BY mkv."namespace", mkv."group", mkv."resource", mkv."name"
) AS maxkv ON maxkv."guid" = kv."guid"
WHERE kv."action" != 3
ORDER BY kv."resource_version" ASC
LIMIT ?, ?;
Loading…
Cancel
Save