Skip to content

Commit

Permalink
Merge pull request #4 from pgguru/tests
Browse files Browse the repository at this point in the history
Add tests
  • Loading branch information
pgguru authored Feb 5, 2024
2 parents 96959f0 + 27492d7 commit 4f43b1d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@

END OF TERMS AND CONDITIONS

Copyright 2022 Crunchy Data Solutions, Inc.
Copyright 2022-2024 Crunchy Data Solutions, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ EXTENSION = pg_kaboom
MODULE_big = pg_kaboom
DATA = pg_kaboom--0.0.1.sql
OBJS = pg_kaboom.o
TAP_TESTS = t/001_basic.pl
PG_CONFIG ?= pg_config
PG_CFLAGS := -Wno-missing-prototypes -Wno-deprecated-declarations -Wno-unused-result
PGXS := $(shell $(PG_CONFIG) --pgxs)
Expand Down
4 changes: 2 additions & 2 deletions pg_kaboom.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022 Crunchy Data Solutions, Inc.
Copyright 2022-2024 Crunchy Data Solutions, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -605,7 +605,7 @@ static void wpn_xact_wrap(WPN_ARGS) {

static void wpn_mem(WPN_ARGS) {
char *size = payload ? simple_get_json_str(payload, "size") : "1GB";
char *context = payload ? simple_get_json_str(payload, "context") : "Current"; /* TODO */
//char *context = payload ? simple_get_json_str(payload, "context") : "Current"; /* TODO */

int64 alloc_size = DatumGetInt64(DirectFunctionCall1(pg_size_bytes, CStringGetDatum(size)));
pfree(palloc(alloc_size));
Expand Down
17 changes: 17 additions & 0 deletions t/001_basic.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env perl
use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use Test::More qw/no_plan/;

my $node = PostgreSQL::Test::Cluster->new('primary');

$node->init();
$node->start();

$node->safe_psql('postgres','CREATE EXTENSION IF NOT EXISTS pg_kaboom');

is ($node->safe_psql('postgres',"select extname from pg_extension where extname = 'pg_kaboom'"),
'pg_kaboom',
'successfully created the extension'
);

0 comments on commit 4f43b1d

Please sign in to comment.