Skip to content

Commit 2114de5

Browse files
committed
chore: add test context
1 parent 1ec1938 commit 2114de5

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

axiom/tests/test_health.c

+25-4
Original file line numberDiff line numberDiff line change
@@ -25,60 +25,81 @@ static void test_health(void) {
2525

2626
nrh_set_start_time();
2727

28+
// ensure clean environment
2829
nr_unlink("health-bc21b5891f5e44fc9272caef924611a8.yml");
2930
nr_unlink("health-ffffffffffffffffffffffffffffffff.yml");
3031

32+
// invalid location
3133
location = nrh_get_health_location("/should/not/exist");
3234
tlib_pass_if_true("initialization to bad path fails", NULL == location,
3335
"location=%s", NULL == location ? "NULL" : location);
3436
nr_free(location);
37+
38+
// invalid uuid
3539
rv = nrh_set_uuid("bc21b5891f5e44fc9272caef924611a");
3640
tlib_pass_if_true("set uuid with invalid length uuid fails", NR_FAILURE == rv,
3741
"rv=%d", (int)rv);
3842

43+
// valid location
3944
location = nrh_get_health_location("file://./");
4045
tlib_pass_if_true("initialization to good path succeeds", NULL != location,
4146
"location=%s", NULL == location ? "NULL" : location);
47+
48+
// valid status
4249
rv = nrh_set_last_error(NRH_INVALID_LICENSE);
50+
51+
// write default uuid + valid location + valid status
4352
rv = nrh_write_health(location);
4453
tlib_pass_if_true("health file write succeeds", NR_SUCCESS == rv, "rv=%d",
4554
(int)rv);
4655
tlib_pass_if_exists("./health-bc21b5891f5e44fc9272caef924611a8.yml");
4756

57+
// update to a new uuid
4858
rv = nrh_set_uuid("ffffffffffffffffffffffffffffffff");
4959
tlib_pass_if_true("set uuid succeeds", NR_SUCCESS == rv, "rv=%d", (int)rv);
60+
61+
// update to a new valid status
5062
rv = nrh_set_last_error(NRH_MISSING_LICENSE);
63+
64+
// write new file (uuid) + same location + new status
5165
rv = nrh_write_health(location);
5266
tlib_pass_if_true("health file write succeeds", NR_SUCCESS == rv, "rv=%d",
5367
(int)rv);
5468
tlib_pass_if_exists("./health-ffffffffffffffffffffffffffffffff.yml");
5569

70+
// update to new valid status
5671
rv = nrh_set_last_error(NRH_MISSING_APPNAME);
57-
rv = nrh_write_health(location);
58-
tlib_pass_if_true("write_health succeeds", NR_SUCCESS == rv, "rv=%d",
59-
(int)rv);
6072

61-
rv = nrh_set_last_error(NRH_HEALTHY);
73+
// update existing file with new status
6274
rv = nrh_write_health(location);
6375
tlib_pass_if_true("write_health succeeds", NR_SUCCESS == rv, "rv=%d",
6476
(int)rv);
6577

78+
// update new random uuid
6679
rv = nrh_set_uuid(NULL);
6780
tlib_pass_if_true("set random uuid succeeds", NR_SUCCESS == rv, "rv=%d",
6881
(int)rv);
82+
83+
// verify new random uuid != previous
6984
rand_uuid = nrh_get_uuid();
7085
tlib_pass_if_not_null("get uuid succeeds", rand_uuid);
7186
tlib_pass_if_true(
7287
"manual uuid successfully replaced by random uuid",
7388
0 != nr_strcmp("ffffffffffffffffffffffffffffffff", rand_uuid), "rand=%s",
7489
rand_uuid);
90+
91+
// update to valid status
7592
rv = nrh_set_last_error(NRH_CONNECTION_FAILED);
93+
94+
// write new file (random uuid) + existing location + new status
7695
rv = nrh_write_health(location);
7796

97+
// test get_health_filename functionality
7898
rand_healthfile = nrh_get_health_filename();
7999
tlib_pass_if_not_null("get health filename succeeds", rand_healthfile);
80100
tlib_pass_if_exists(rand_healthfile);
81101

102+
// clean up
82103
nr_unlink("health-bc21b5891f5e44fc9272caef924611a8.yml");
83104
nr_unlink("health-ffffffffffffffffffffffffffffffff.yml");
84105
nr_unlink(rand_healthfile);

0 commit comments

Comments
 (0)