Skip to content

Commit 6f78546

Browse files
i10416claude
andcommitted
Improve mail operator tests to correctly simulate variable substitution
The previous tests used ${address_list} as literal strings, which didn't properly demonstrate how the parseList fix works. Updated tests now use JSON string representations like ["a@ex.com", "b@ex.com"] which correctly simulates what happens after Digdag's template engine processes variables. This matches the pattern used in Config.verifyParseList() test and clearly demonstrates that parseList can handle JSON strings while getList cannot. Added detailed comments explaining the variable substitution process. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 53db792 commit 6f78546

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

digdag-standards/src/test/java/io/digdag/standards/operator/MailOperatorFactoryTest.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,27 +357,36 @@ public void errorCheckStringBcc()
357357
@Test
358358
public void sendToWithArrayVariable()
359359
{
360+
// This test simulates what happens when you write:
361+
// _export:
362+
// address_list: ["bob@example.com", "charlie@example.com"]
363+
// +task:
364+
// mail>:
365+
// to: ${address_list}
366+
//
367+
// After template substitution, the "to" parameter becomes a JSON string like:
368+
// '["bob@example.com", "charlie@example.com"]'
369+
//
370+
// The parseList method should parse this JSON string and convert it to a List
360371
Config config = mailConfig.deepCopy();
361-
config.set("to", "${address_list}");
362-
config.getNestedOrSetEmpty("_export")
363-
.set("address_list", ImmutableList.of("bob@example.com", "charlie@example.com"));
372+
config.set("to", "[\"bob@example.com\", \"charlie@example.com\"]");
364373

365374
Operator op = factory.newOperator(newContext(
366375
tempPath,
367376
newTaskRequest().withConfig(config)));
368377
op.run();
378+
greenMail.waitForIncomingEmail(5000, 2);
369379
receiveCheck("bob@example.com", 1);
370380
receiveCheck("charlie@example.com", 1);
371381
}
372382

373383
@Test
374384
public void sendCcWithArrayVariable()
375385
{
386+
// After template substitution, the "cc" parameter becomes a JSON string
376387
Config config = mailConfig.deepCopy();
377388
config.set("to", "bob@example.com");
378-
config.set("cc", "${cc_list}");
379-
config.getNestedOrSetEmpty("_export")
380-
.set("cc_list", ImmutableList.of("charlie@example.com", "david@example.com"));
389+
config.set("cc", "[\"charlie@example.com\", \"david@example.com\"]");
381390

382391
Operator op = factory.newOperator(newContext(
383392
tempPath,
@@ -392,11 +401,10 @@ public void sendCcWithArrayVariable()
392401
@Test
393402
public void sendBccWithArrayVariable()
394403
{
404+
// After template substitution, the "bcc" parameter becomes a JSON string
395405
Config config = mailConfig.deepCopy();
396406
config.set("to", "bob@example.com");
397-
config.set("bcc", "${bcc_list}");
398-
config.getNestedOrSetEmpty("_export")
399-
.set("bcc_list", ImmutableList.of("charlie@example.com", "david@example.com"));
407+
config.set("bcc", "[\"charlie@example.com\", \"david@example.com\"]");
400408

401409
Operator op = factory.newOperator(newContext(
402410
tempPath,

0 commit comments

Comments
 (0)