Skip to content

Commit

Permalink
Merge pull request #2361 from demergent-labs/get_canister_actor
Browse files Browse the repository at this point in the history
All prop tests use getCanisterActor
  • Loading branch information
lastmjs authored Dec 20, 2024
2 parents c43a7f4 + f8cd5e6 commit f3decce
Show file tree
Hide file tree
Showing 86 changed files with 178 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function generateTests(
{
name: `blob ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
...paramBlobs.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function generateTests(
{
name: `bool ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function generateTests(
{
name: 'get state before calling http_request',
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor['get_state']();

Expand Down Expand Up @@ -62,7 +62,7 @@ export function generateTests(
{
name: 'get state after calling http_request',
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor['get_state']();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function generateTests(
{
name: `init method`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);
const result = await actor.getInitValues();

return testEquality(result, expectedResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function generateTest(
name: `method "${functionName}" expected ${behavior}`,
test: async (): Promise<AzleResult> => {
await agent.fetchRootKey();
const actor = getActor(__dirname, agent);
const actor = await getActor(__dirname, agent);
try {
const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function generateTests(
{
name: `init method`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const initValues = await actor.getInitValues();
const isPostUpgradeCalled =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function generateTests(
{
name: `post upgrade method`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const postUpgradeValues =
await actor.getPostUpgradeValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function generateGetPreUpgradeExecutedCanisterMethod(): QueryMethod {
{
name: `pre upgrade was not called after first deploy`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);
const result = await actor.getPreUpgradeExecuted();

return testEquality(result, []);
Expand All @@ -135,7 +135,7 @@ function generateGetPreUpgradeExecutedCanisterMethod(): QueryMethod {
{
name: `pre upgrade was called after second deploy`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);
const result = await actor.getPreUpgradeExecuted();

return testEquality(result, [true]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function generateTests(
{
name: `query method "${functionName}"`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);
const result = await actor[functionName](...paramValues);
return testEquality(result, expectedResult);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function generateTests(
{
name: `update method "${functionName}"`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);
const result = await actor[functionName](...paramValues);

return testEquality(result, expectedResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function generateTests(
{
name: `float32 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTests(
{
name: `float64 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function generateTests(
{
name: `func ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
...namedParamFuncs.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function generateTests(
{
name: `int ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTests(
{
name: `int16 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTests(
{
name: `int32 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function generateTests(
{
name: `int64 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function generateTests(
{
name: `test ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function generateTests(
{
name: `nat ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTests(
{
name: `nat16 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTests(
{
name: `nat32 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function generateTests(
{
name: `nat64 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function generateTests(
{
name: `nat8 ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](...paramValues);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function generateTests(
{
name: `test ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
...namedParamNulls.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function generateTests(
{
name: `opt ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const params = namedParamOpts.map(
(param) => param.value.value.agentArgumentValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function generateTests(
{
name: `principal ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);
const result = await actor[functionName](
...namedParamPrincipals.map(
(param) => param.value.value.agentArgumentValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function generateTests(
{
name: `record ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
...namedParamRecords.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function generateTests(
{
name: `recursive ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const params = namedParamRecursive.map(
(param) => param.value.value.agentArgumentValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function generateTests(
{
name: `containsKey after first deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue
Expand All @@ -68,7 +68,7 @@ function generateTests(
{
name: `containsKey after second deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue
Expand All @@ -82,7 +82,7 @@ function generateTests(
{
name: `containsKey after third deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function generateTests(
{
name: `get after first deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue
Expand All @@ -86,7 +86,7 @@ function generateTests(
{
name: `get after second deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue
Expand All @@ -102,7 +102,7 @@ function generateTests(
{
name: `get after third deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function generateTests(
{
name: `insert after first deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName](
keySampleAgentArgumentValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function generateTests(functionName: string): Test[][] {
{
name: `isEmpty after first deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName]();

Expand All @@ -56,7 +56,7 @@ function generateTests(functionName: string): Test[][] {
{
name: `isEmpty after second deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName]();

Expand All @@ -68,7 +68,7 @@ function generateTests(functionName: string): Test[][] {
{
name: `isEmpty after third deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName]();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function generateTests(
{
name: `items after first deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName]();

Expand All @@ -71,7 +71,7 @@ function generateTests(
{
name: `items after second deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName]();

Expand All @@ -88,7 +88,7 @@ function generateTests(
{
name: `items after third deploy ${functionName}`,
test: async (): Promise<AzleResult> => {
const actor = getActor(__dirname);
const actor = await getActor(__dirname);

const result = await actor[functionName]();

Expand Down
Loading

0 comments on commit f3decce

Please sign in to comment.