2023-02-02 17:15:17 -08:00
|
|
|
-- Copyright (c) HashiCorp, Inc.
|
2021-08-11 13:25:32 -04:00
|
|
|
-- SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2021-08-11 13:25:32 -04:00
|
|
|
-- insert tests that the wh_upsert_user function will do an insert when
|
|
|
|
|
-- no existing source wh_user_dimension exists.
|
|
|
|
|
begin;
|
|
|
|
|
select plan(3);
|
|
|
|
|
|
|
|
|
|
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets');
|
|
|
|
|
|
|
|
|
|
-- ensure no existing dimensions
|
2024-01-08 16:28:37 +00:00
|
|
|
select is(count(*), 0::bigint) from wh_user_dimension where user_id = 'u_____wilson';
|
2021-08-11 13:25:32 -04:00
|
|
|
|
2024-01-08 16:28:37 +00:00
|
|
|
select lives_ok($$select wh_upsert_user('tok___wilson')$$);
|
2021-08-11 13:25:32 -04:00
|
|
|
|
|
|
|
|
-- upsert should insert a user_dimension
|
2024-01-08 16:28:37 +00:00
|
|
|
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____wilson';
|
2021-08-11 13:25:32 -04:00
|
|
|
|
|
|
|
|
select * from finish();
|
|
|
|
|
rollback;
|