Skip to content

Commit

Permalink
add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Jul 30, 2024
1 parent 4d26cb3 commit 3910d49
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cloudv2/test/counter/aws-counter.test.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
bring cloud;
bring aws;
bring util;

let target = util.env("WING_TARGET");

let counter = new cloud.Counter(initial: 1) as "aws-wing-counter";

let getCounterInfo = (c: cloud.Counter): Map<str>? => {
if let counter = aws.Counter.from(c) {
return {
dynamoTableArn: counter.dynamoTableArn,
dynamoTableName: counter.dynamoTableName,
};
}
return nil;
};

let counterInfo = getCounterInfo(counter);

test "validates the AWS counter name" {
if let counter = counterInfo {
if target == "tf-aws" {
assert(counter.get("dynamoTableArn").contains("arn:aws:dynamodb:"));
assert(counter.get("dynamoTableArn").contains("aws-wing-counter"));
assert(counter.get("dynamoTableName").contains("aws-wing-counter"));
} else {
assert(counter.get("dynamoTableArn").contains("arn:aws:dynamodb:"));
assert(counter.get("dynamoTableArn").contains("awswingcounter"));
assert(counter.get("dynamoTableName").contains("awswingcounter"));
}
} else {
// If the test is not on AWS, it should not fail, so I am returning true.
assert(true);
}
}

0 comments on commit 3910d49

Please sign in to comment.