Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
add 'stop' test
Browse files Browse the repository at this point in the history
  • Loading branch information
eladb committed Oct 9, 2023
1 parent a660f6d commit 055951f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
6 changes: 4 additions & 2 deletions api.w
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
interface IWorkload {
/** starts the workload */
/** starts the container */
inflight start(): void;

/** stops containers */
/** stops the container */
inflight stop(): void;

/** if `port` is specified, this includes the external url of the container */
inflight url(): str?;
}

Expand Down
30 changes: 26 additions & 4 deletions test/containers.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,32 @@ let hello = new containers.Workload(
}
);

test "workload started" {
let getBody = inflight (): str? => {
if let url = hello.url() {
assert(http.get(url).body?.contains(message) ?? false);
} else {
assert(false);
return http.get(url).body;
}

return nil;
};


test "container started automatically and port exposed" {
let body = getBody();
assert(body?.contains(message) ?? false);
}

test "container stopped after stop() is called" {
assert(getBody()?);

// stop the container and check that there is no body
hello.stop();

// check that we can't reach the container
let var error = false;
try {
getBody();
} catch {
error = true;
}
assert(error);
}

0 comments on commit 055951f

Please sign in to comment.