Skip to content

Commit f1b161f

Browse files
committed
use checks in test modules
1 parent e0ea4a2 commit f1b161f

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

tests/sample-jhub-nfs/main.tf

+14
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,17 @@ module "sample-jhub" {
7777
scale_down_command = ["kubectl", "scale", "--replicas=0", "statefulset/user-placeholder"]
7878

7979
}
80+
81+
check "jhub_running" {
82+
# Use a data block to check the website
83+
data "http" "jhub_check" {
84+
url = output.sample_website.jhub_url
85+
method = "GET"
86+
}
87+
88+
# Check if the website returns a successful status code
89+
assert {
90+
condition = data.http.jhub_check.status_code == 200
91+
error_message = "Website did not return a 200 OK status. Actual status: ${data.http.website_check.status_code}"
92+
}
93+
}

tests/sample-jhub/main.tf

+13
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,16 @@ module "sample-jhub" {
7878
scale_down_command = ["kubectl", "scale", "--replicas=0", "statefulset/user-placeholder"]
7979

8080
}
81+
82+
check "jhub_running" {
83+
data "http" "jhub_check" {
84+
url = output.sample_website.jhub_url
85+
method = "GET"
86+
}
87+
88+
# Check if the website returns a successful status code
89+
assert {
90+
condition = data.http.jhub_check.status_code == 200
91+
error_message = "Website did not return a 200 OK status. Actual status: ${data.http.website_check.status_code}"
92+
}
93+
}

tests/test-sample-jhub-nfs.tftest.hcl

-12
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,4 @@ run "test_website_creation" {
1111
condition = output.sample_website.jhub_url != ""
1212
error_message = "Website URL is empty"
1313
}
14-
15-
# Use a data block to check the website
16-
data "http" "jhub_check" {
17-
url = output.sample_website.jhub_url
18-
method = "GET"
19-
}
20-
21-
# Check if the website returns a successful status code
22-
assert {
23-
condition = data.http.jhub_check.status_code == 200
24-
error_message = "Website did not return a 200 OK status. Actual status: ${data.http.website_check.status_code}"
25-
}
2614
}

tests/test-sample-jhub.tftest.hcl

-12
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,4 @@ run "test_website_creation" {
1111
condition = output.sample_website.jhub_url != ""
1212
error_message = "Website URL is empty"
1313
}
14-
15-
# Use a data block to check the website
16-
data "http" "jhub_check" {
17-
url = output.sample_website.jhub_url
18-
method = "GET"
19-
}
20-
21-
# Check if the website returns a successful status code
22-
assert {
23-
condition = data.http.jhub_check.status_code == 200
24-
error_message = "Website did not return a 200 OK status. Actual status: ${data.http.website_check.status_code}"
25-
}
2614
}

0 commit comments

Comments
 (0)