github.com/tkak/terraform@v0.5.4-0.20150712180941-7f738dc27225/terraform/terraform_test.go (about) 1 package terraform 2 3 import ( 4 "bytes" 5 "crypto/sha1" 6 "encoding/gob" 7 "encoding/hex" 8 "fmt" 9 "io/ioutil" 10 "os" 11 "path/filepath" 12 "strings" 13 "sync" 14 "testing" 15 16 "github.com/hashicorp/terraform/config" 17 "github.com/hashicorp/terraform/config/module" 18 ) 19 20 // This is the directory where our test fixtures are. 21 const fixtureDir = "./test-fixtures" 22 23 func checksumStruct(t *testing.T, i interface{}) string { 24 // TODO(mitchellh): write a library to do this because gob is not 25 // deterministic in order 26 return "foo" 27 28 buf := new(bytes.Buffer) 29 enc := gob.NewEncoder(buf) 30 if err := enc.Encode(i); err != nil { 31 t.Fatalf("err: %s", err) 32 } 33 34 sum := sha1.Sum(buf.Bytes()) 35 return hex.EncodeToString(sum[:]) 36 } 37 38 func tempDir(t *testing.T) string { 39 dir, err := ioutil.TempDir("", "tf") 40 if err != nil { 41 t.Fatalf("err: %s", err) 42 } 43 if err := os.RemoveAll(dir); err != nil { 44 t.Fatalf("err: %s", err) 45 } 46 47 return dir 48 } 49 50 // tempEnv lets you temporarily set an environment variable. It returns 51 // the old value that should be set via a defer. 52 func tempEnv(t *testing.T, k string, v string) string { 53 old := os.Getenv(k) 54 os.Setenv(k, v) 55 return old 56 } 57 58 func testConfig(t *testing.T, name string) *config.Config { 59 c, err := config.LoadFile(filepath.Join(fixtureDir, name, "main.tf")) 60 if err != nil { 61 t.Fatalf("err: %s", err) 62 } 63 64 return c 65 } 66 67 func testModule(t *testing.T, name string) *module.Tree { 68 mod, err := module.NewTreeModule("", filepath.Join(fixtureDir, name)) 69 if err != nil { 70 t.Fatalf("err: %s", err) 71 } 72 73 s := &module.FolderStorage{StorageDir: tempDir(t)} 74 if err := mod.Load(s, module.GetModeGet); err != nil { 75 t.Fatalf("err: %s", err) 76 } 77 78 return mod 79 } 80 81 func testStringMatch(t *testing.T, s fmt.Stringer, expected string) { 82 actual := strings.TrimSpace(s.String()) 83 expected = strings.TrimSpace(expected) 84 if actual != expected { 85 t.Fatalf("Actual\n\n%s\n\nExpected:\n\n%s", actual, expected) 86 } 87 } 88 89 func testProviderFuncFixed(rp ResourceProvider) ResourceProviderFactory { 90 return func() (ResourceProvider, error) { 91 return rp, nil 92 } 93 } 94 95 func testProvisionerFuncFixed(rp ResourceProvisioner) ResourceProvisionerFactory { 96 return func() (ResourceProvisioner, error) { 97 return rp, nil 98 } 99 } 100 101 // HookRecordApplyOrder is a test hook that records the order of applies 102 // by recording the PreApply event. 103 type HookRecordApplyOrder struct { 104 NilHook 105 106 Active bool 107 108 IDs []string 109 States []*InstanceState 110 Diffs []*InstanceDiff 111 112 l sync.Mutex 113 } 114 115 func (h *HookRecordApplyOrder) PreApply( 116 info *InstanceInfo, 117 s *InstanceState, 118 d *InstanceDiff) (HookAction, error) { 119 if h.Active { 120 h.l.Lock() 121 defer h.l.Unlock() 122 123 h.IDs = append(h.IDs, info.Id) 124 h.Diffs = append(h.Diffs, d) 125 h.States = append(h.States, s) 126 } 127 128 return HookActionContinue, nil 129 } 130 131 // Below are all the constant strings that are the expected output for 132 // various tests. 133 134 const testTerraformInputProviderStr = ` 135 aws_instance.bar: 136 ID = foo 137 bar = override 138 foo = us-east-1 139 type = aws_instance 140 aws_instance.foo: 141 ID = foo 142 bar = baz 143 num = 2 144 type = aws_instance 145 ` 146 147 const testTerraformInputProviderOnlyStr = ` 148 aws_instance.foo: 149 ID = foo 150 foo = us-west-2 151 type = aws_instance 152 ` 153 154 const testTerraformInputVarOnlyStr = ` 155 aws_instance.foo: 156 ID = foo 157 foo = us-east-1 158 type = aws_instance 159 ` 160 161 const testTerraformInputVarOnlyUnsetStr = ` 162 aws_instance.foo: 163 ID = foo 164 bar = baz 165 foo = foovalue 166 type = aws_instance 167 ` 168 169 const testTerraformInputVarsStr = ` 170 aws_instance.bar: 171 ID = foo 172 bar = override 173 foo = us-east-1 174 type = aws_instance 175 aws_instance.foo: 176 ID = foo 177 bar = baz 178 num = 2 179 type = aws_instance 180 ` 181 182 const testTerraformApplyStr = ` 183 aws_instance.bar: 184 ID = foo 185 foo = bar 186 type = aws_instance 187 aws_instance.foo: 188 ID = foo 189 num = 2 190 type = aws_instance 191 ` 192 193 const testTerraformApplyProviderAliasStr = ` 194 aws_instance.bar: 195 ID = foo 196 provider = aws.bar 197 foo = bar 198 type = aws_instance 199 aws_instance.foo: 200 ID = foo 201 num = 2 202 type = aws_instance 203 ` 204 205 const testTerraformApplyEmptyModuleStr = ` 206 <no state> 207 Outputs: 208 209 end = XXXX 210 211 module.child: 212 <no state> 213 Outputs: 214 215 aws_access_key = YYYYY 216 aws_route53_zone_id = XXXX 217 aws_secret_key = ZZZZ 218 ` 219 220 const testTerraformApplyDependsCreateBeforeStr = ` 221 aws_instance.lb: 222 ID = foo 223 instance = foo 224 type = aws_instance 225 226 Dependencies: 227 aws_instance.web 228 aws_instance.web: 229 ID = foo 230 require_new = ami-new 231 type = aws_instance 232 ` 233 234 const testTerraformApplyCreateBeforeStr = ` 235 aws_instance.bar: 236 ID = foo 237 require_new = xyz 238 type = aws_instance 239 ` 240 241 const testTerraformApplyCreateBeforeUpdateStr = ` 242 aws_instance.bar: 243 ID = foo 244 foo = baz 245 type = aws_instance 246 ` 247 248 const testTerraformApplyCancelStr = ` 249 aws_instance.foo: 250 ID = foo 251 num = 2 252 ` 253 254 const testTerraformApplyComputeStr = ` 255 aws_instance.bar: 256 ID = foo 257 foo = computed_dynamical 258 type = aws_instance 259 260 Dependencies: 261 aws_instance.foo 262 aws_instance.foo: 263 ID = foo 264 dynamical = computed_dynamical 265 num = 2 266 type = aws_instance 267 ` 268 269 const testTerraformApplyCountDecStr = ` 270 aws_instance.foo.0: 271 ID = bar 272 foo = foo 273 type = aws_instance 274 aws_instance.foo.1: 275 ID = bar 276 foo = foo 277 type = aws_instance 278 ` 279 280 const testTerraformApplyCountDecToOneStr = ` 281 aws_instance.foo: 282 ID = bar 283 foo = foo 284 type = aws_instance 285 ` 286 287 const testTerraformApplyCountDecToOneCorruptedStr = ` 288 aws_instance.foo: 289 ID = bar 290 foo = foo 291 type = aws_instance 292 ` 293 294 const testTerraformApplyCountDecToOneCorruptedPlanStr = ` 295 DIFF: 296 297 DESTROY: aws_instance.foo.0 298 299 STATE: 300 301 aws_instance.foo: 302 ID = bar 303 foo = foo 304 type = aws_instance 305 aws_instance.foo.0: 306 ID = baz 307 type = aws_instance 308 ` 309 310 const testTerraformApplyCountTaintedStr = ` 311 <no state> 312 ` 313 314 const testTerraformApplyCountVariableStr = ` 315 aws_instance.foo.0: 316 ID = foo 317 foo = foo 318 type = aws_instance 319 aws_instance.foo.1: 320 ID = foo 321 foo = foo 322 type = aws_instance 323 ` 324 325 const testTerraformApplyMinimalStr = ` 326 aws_instance.bar: 327 ID = foo 328 aws_instance.foo: 329 ID = foo 330 ` 331 332 const testTerraformApplyModuleStr = ` 333 aws_instance.bar: 334 ID = foo 335 foo = bar 336 type = aws_instance 337 aws_instance.foo: 338 ID = foo 339 num = 2 340 type = aws_instance 341 342 module.child: 343 aws_instance.baz: 344 ID = foo 345 foo = bar 346 type = aws_instance 347 ` 348 349 const testTerraformApplyModuleBoolStr = ` 350 aws_instance.bar: 351 ID = foo 352 foo = 1 353 type = aws_instance 354 355 Dependencies: 356 module.child 357 358 module.child: 359 <no state> 360 Outputs: 361 362 leader = 1 363 ` 364 365 const testTerraformApplyModuleDestroyOrderStr = ` 366 <no state> 367 module.child: 368 <no state> 369 ` 370 371 const testTerraformApplyMultiProviderStr = ` 372 aws_instance.bar: 373 ID = foo 374 foo = bar 375 type = aws_instance 376 do_instance.foo: 377 ID = foo 378 num = 2 379 type = do_instance 380 ` 381 382 const testTerraformApplyModuleOnlyProviderStr = ` 383 <no state> 384 module.child: 385 aws_instance.foo: 386 ID = foo 387 test_instance.foo: 388 ID = foo 389 ` 390 391 const testTerraformApplyModuleProviderAliasStr = ` 392 <no state> 393 module.child: 394 aws_instance.foo: 395 ID = foo 396 provider = aws.eu 397 ` 398 399 const testTerraformApplyOutputOrphanStr = ` 400 <no state> 401 Outputs: 402 403 foo = bar 404 ` 405 406 const testTerraformApplyProvisionerStr = ` 407 aws_instance.bar: 408 ID = foo 409 410 Dependencies: 411 aws_instance.foo 412 aws_instance.foo: 413 ID = foo 414 dynamical = computed_dynamical 415 num = 2 416 type = aws_instance 417 ` 418 419 const testTerraformApplyProvisionerFailStr = ` 420 aws_instance.bar: (1 tainted) 421 ID = <not created> 422 Tainted ID 1 = foo 423 aws_instance.foo: 424 ID = foo 425 num = 2 426 type = aws_instance 427 ` 428 429 const testTerraformApplyProvisionerFailCreateStr = ` 430 aws_instance.bar: (1 tainted) 431 ID = <not created> 432 Tainted ID 1 = foo 433 ` 434 435 const testTerraformApplyProvisionerFailCreateNoIdStr = ` 436 <no state> 437 ` 438 439 const testTerraformApplyProvisionerFailCreateBeforeDestroyStr = ` 440 aws_instance.bar: (1 tainted) 441 ID = bar 442 require_new = abc 443 Tainted ID 1 = foo 444 ` 445 446 const testTerraformApplyProvisionerResourceRefStr = ` 447 aws_instance.bar: 448 ID = foo 449 num = 2 450 type = aws_instance 451 ` 452 453 const testTerraformApplyProvisionerSelfRefStr = ` 454 aws_instance.foo: 455 ID = foo 456 foo = bar 457 type = aws_instance 458 ` 459 460 const testTerraformApplyProvisionerMultiSelfRefStr = ` 461 aws_instance.foo.0: 462 ID = foo 463 foo = number 0 464 type = aws_instance 465 aws_instance.foo.1: 466 ID = foo 467 foo = number 1 468 type = aws_instance 469 aws_instance.foo.2: 470 ID = foo 471 foo = number 2 472 type = aws_instance 473 ` 474 475 const testTerraformApplyProvisionerDiffStr = ` 476 aws_instance.bar: 477 ID = foo 478 foo = bar 479 type = aws_instance 480 ` 481 482 const testTerraformApplyDestroyStr = ` 483 <no state> 484 ` 485 486 const testTerraformApplyErrorStr = ` 487 aws_instance.bar: 488 ID = bar 489 490 Dependencies: 491 aws_instance.foo 492 aws_instance.foo: 493 ID = foo 494 num = 2 495 ` 496 497 const testTerraformApplyErrorCreateBeforeDestroyStr = ` 498 aws_instance.bar: 499 ID = bar 500 require_new = abc 501 ` 502 503 const testTerraformApplyErrorDestroyCreateBeforeDestroyStr = ` 504 aws_instance.bar: (1 deposed) 505 ID = foo 506 Deposed ID 1 = bar 507 ` 508 509 const testTerraformApplyErrorPartialStr = ` 510 aws_instance.bar: 511 ID = bar 512 513 Dependencies: 514 aws_instance.foo 515 aws_instance.foo: 516 ID = foo 517 num = 2 518 ` 519 520 const testTerraformApplyTaintStr = ` 521 aws_instance.bar: 522 ID = foo 523 num = 2 524 type = aws_instance 525 ` 526 527 const testTerraformApplyTaintDepStr = ` 528 aws_instance.bar: 529 ID = bar 530 foo = foo 531 num = 2 532 type = aws_instance 533 534 Dependencies: 535 aws_instance.foo 536 aws_instance.foo: 537 ID = foo 538 num = 2 539 type = aws_instance 540 ` 541 542 const testTerraformApplyTaintDepRequireNewStr = ` 543 aws_instance.bar: 544 ID = foo 545 foo = foo 546 require_new = yes 547 type = aws_instance 548 549 Dependencies: 550 aws_instance.foo 551 aws_instance.foo: 552 ID = foo 553 num = 2 554 type = aws_instance 555 ` 556 557 const testTerraformApplyOutputStr = ` 558 aws_instance.bar: 559 ID = foo 560 foo = bar 561 type = aws_instance 562 aws_instance.foo: 563 ID = foo 564 num = 2 565 type = aws_instance 566 567 Outputs: 568 569 foo_num = 2 570 ` 571 572 const testTerraformApplyOutputListStr = ` 573 aws_instance.bar.0: 574 ID = foo 575 foo = bar 576 type = aws_instance 577 aws_instance.bar.1: 578 ID = foo 579 foo = bar 580 type = aws_instance 581 aws_instance.bar.2: 582 ID = foo 583 foo = bar 584 type = aws_instance 585 aws_instance.foo: 586 ID = foo 587 num = 2 588 type = aws_instance 589 590 Outputs: 591 592 foo_num = bar,bar,bar 593 ` 594 595 const testTerraformApplyOutputMultiStr = ` 596 aws_instance.bar.0: 597 ID = foo 598 foo = bar 599 type = aws_instance 600 aws_instance.bar.1: 601 ID = foo 602 foo = bar 603 type = aws_instance 604 aws_instance.bar.2: 605 ID = foo 606 foo = bar 607 type = aws_instance 608 aws_instance.foo: 609 ID = foo 610 num = 2 611 type = aws_instance 612 613 Outputs: 614 615 foo_num = bar,bar,bar 616 ` 617 618 const testTerraformApplyOutputMultiIndexStr = ` 619 aws_instance.bar.0: 620 ID = foo 621 foo = bar 622 type = aws_instance 623 aws_instance.bar.1: 624 ID = foo 625 foo = bar 626 type = aws_instance 627 aws_instance.bar.2: 628 ID = foo 629 foo = bar 630 type = aws_instance 631 aws_instance.foo: 632 ID = foo 633 num = 2 634 type = aws_instance 635 636 Outputs: 637 638 foo_num = bar 639 ` 640 641 const testTerraformApplyUnknownAttrStr = ` 642 aws_instance.foo: 643 ID = foo 644 num = 2 645 type = aws_instance 646 ` 647 648 const testTerraformApplyVarsStr = ` 649 aws_instance.bar: 650 ID = foo 651 bar = foo 652 baz = override 653 foo = us-west-2 654 type = aws_instance 655 aws_instance.foo: 656 ID = foo 657 bar = baz 658 num = 2 659 type = aws_instance 660 ` 661 662 const testTerraformApplyVarsEnvStr = ` 663 aws_instance.bar: 664 ID = foo 665 foo = baz 666 type = aws_instance 667 ` 668 669 const testTerraformPlanStr = ` 670 DIFF: 671 672 CREATE: aws_instance.bar 673 foo: "" => "2" 674 type: "" => "aws_instance" 675 CREATE: aws_instance.foo 676 num: "" => "2" 677 type: "" => "aws_instance" 678 679 STATE: 680 681 <no state> 682 ` 683 684 const testTerraformPlanComputedStr = ` 685 DIFF: 686 687 CREATE: aws_instance.bar 688 foo: "" => "<computed>" 689 type: "" => "aws_instance" 690 CREATE: aws_instance.foo 691 foo: "" => "<computed>" 692 num: "" => "2" 693 type: "" => "aws_instance" 694 695 STATE: 696 697 <no state> 698 ` 699 700 const testTerraformPlanComputedIdStr = ` 701 DIFF: 702 703 CREATE: aws_instance.bar 704 foo: "" => "<computed>" 705 type: "" => "aws_instance" 706 CREATE: aws_instance.foo 707 foo: "" => "<computed>" 708 num: "" => "2" 709 type: "" => "aws_instance" 710 711 STATE: 712 713 <no state> 714 ` 715 716 const testTerraformPlanComputedListStr = ` 717 DIFF: 718 719 CREATE: aws_instance.bar 720 foo: "" => "<computed>" 721 type: "" => "aws_instance" 722 CREATE: aws_instance.foo 723 list.#: "" => "<computed>" 724 num: "" => "2" 725 type: "" => "aws_instance" 726 727 STATE: 728 729 <no state> 730 ` 731 732 const testTerraformPlanCountStr = ` 733 DIFF: 734 735 CREATE: aws_instance.bar 736 foo: "" => "foo,foo,foo,foo,foo" 737 type: "" => "aws_instance" 738 CREATE: aws_instance.foo.0 739 foo: "" => "foo" 740 type: "" => "aws_instance" 741 CREATE: aws_instance.foo.1 742 foo: "" => "foo" 743 type: "" => "aws_instance" 744 CREATE: aws_instance.foo.2 745 foo: "" => "foo" 746 type: "" => "aws_instance" 747 CREATE: aws_instance.foo.3 748 foo: "" => "foo" 749 type: "" => "aws_instance" 750 CREATE: aws_instance.foo.4 751 foo: "" => "foo" 752 type: "" => "aws_instance" 753 754 STATE: 755 756 <no state> 757 ` 758 759 const testTerraformPlanCountIndexStr = ` 760 DIFF: 761 762 CREATE: aws_instance.foo.0 763 foo: "" => "0" 764 type: "" => "aws_instance" 765 CREATE: aws_instance.foo.1 766 foo: "" => "1" 767 type: "" => "aws_instance" 768 769 STATE: 770 771 <no state> 772 ` 773 774 const testTerraformPlanCountIndexZeroStr = ` 775 DIFF: 776 777 CREATE: aws_instance.foo 778 foo: "" => "0" 779 type: "" => "aws_instance" 780 781 STATE: 782 783 <no state> 784 ` 785 786 const testTerraformPlanCountOneIndexStr = ` 787 DIFF: 788 789 CREATE: aws_instance.bar 790 foo: "" => "foo" 791 type: "" => "aws_instance" 792 CREATE: aws_instance.foo 793 foo: "" => "foo" 794 type: "" => "aws_instance" 795 796 STATE: 797 798 <no state> 799 ` 800 801 const testTerraformPlanCountZeroStr = ` 802 DIFF: 803 804 CREATE: aws_instance.bar 805 foo: "" => "" 806 type: "" => "aws_instance" 807 808 STATE: 809 810 <no state> 811 ` 812 813 const testTerraformPlanCountVarStr = ` 814 DIFF: 815 816 CREATE: aws_instance.bar 817 foo: "" => "foo,foo,foo" 818 type: "" => "aws_instance" 819 CREATE: aws_instance.foo.0 820 foo: "" => "foo" 821 type: "" => "aws_instance" 822 CREATE: aws_instance.foo.1 823 foo: "" => "foo" 824 type: "" => "aws_instance" 825 CREATE: aws_instance.foo.2 826 foo: "" => "foo" 827 type: "" => "aws_instance" 828 829 STATE: 830 831 <no state> 832 ` 833 834 const testTerraformPlanCountDecreaseStr = ` 835 DIFF: 836 837 CREATE: aws_instance.bar 838 foo: "" => "bar" 839 type: "" => "aws_instance" 840 DESTROY: aws_instance.foo.1 841 DESTROY: aws_instance.foo.2 842 843 STATE: 844 845 aws_instance.foo.0: 846 ID = bar 847 foo = foo 848 type = aws_instance 849 aws_instance.foo.1: 850 ID = bar 851 aws_instance.foo.2: 852 ID = bar 853 ` 854 855 const testTerraformPlanCountIncreaseStr = ` 856 DIFF: 857 858 CREATE: aws_instance.bar 859 foo: "" => "bar" 860 type: "" => "aws_instance" 861 CREATE: aws_instance.foo.1 862 foo: "" => "foo" 863 type: "" => "aws_instance" 864 CREATE: aws_instance.foo.2 865 foo: "" => "foo" 866 type: "" => "aws_instance" 867 868 STATE: 869 870 aws_instance.foo: 871 ID = bar 872 foo = foo 873 type = aws_instance 874 ` 875 876 const testTerraformPlanCountIncreaseFromOneStr = ` 877 DIFF: 878 879 CREATE: aws_instance.bar 880 foo: "" => "bar" 881 type: "" => "aws_instance" 882 CREATE: aws_instance.foo.1 883 foo: "" => "foo" 884 type: "" => "aws_instance" 885 CREATE: aws_instance.foo.2 886 foo: "" => "foo" 887 type: "" => "aws_instance" 888 889 STATE: 890 891 aws_instance.foo.0: 892 ID = bar 893 foo = foo 894 type = aws_instance 895 ` 896 897 const testTerraformPlanCountIncreaseFromOneCorruptedStr = ` 898 DIFF: 899 900 CREATE: aws_instance.bar 901 foo: "" => "bar" 902 type: "" => "aws_instance" 903 DESTROY: aws_instance.foo 904 CREATE: aws_instance.foo.1 905 foo: "" => "foo" 906 type: "" => "aws_instance" 907 CREATE: aws_instance.foo.2 908 foo: "" => "foo" 909 type: "" => "aws_instance" 910 911 STATE: 912 913 aws_instance.foo: 914 ID = bar 915 foo = foo 916 type = aws_instance 917 aws_instance.foo.0: 918 ID = bar 919 foo = foo 920 type = aws_instance 921 ` 922 923 const testTerraformPlanDestroyStr = ` 924 DIFF: 925 926 DESTROY: aws_instance.one 927 DESTROY: aws_instance.two 928 929 STATE: 930 931 aws_instance.one: 932 ID = bar 933 aws_instance.two: 934 ID = baz 935 ` 936 937 const testTerraformPlanDiffVarStr = ` 938 DIFF: 939 940 CREATE: aws_instance.bar 941 num: "" => "3" 942 type: "" => "aws_instance" 943 UPDATE: aws_instance.foo 944 num: "2" => "3" 945 946 STATE: 947 948 aws_instance.foo: 949 ID = bar 950 num = 2 951 ` 952 953 const testTerraformPlanEmptyStr = ` 954 DIFF: 955 956 CREATE: aws_instance.bar 957 CREATE: aws_instance.foo 958 959 STATE: 960 961 <no state> 962 ` 963 964 const testTerraformPlanModulesStr = ` 965 DIFF: 966 967 CREATE: aws_instance.bar 968 foo: "" => "2" 969 type: "" => "aws_instance" 970 CREATE: aws_instance.foo 971 num: "" => "2" 972 type: "" => "aws_instance" 973 974 module.child: 975 CREATE: aws_instance.foo 976 num: "" => "2" 977 type: "" => "aws_instance" 978 979 STATE: 980 981 <no state> 982 ` 983 984 const testTerraformPlanModuleCycleStr = ` 985 DIFF: 986 987 CREATE: aws_instance.b 988 CREATE: aws_instance.c 989 some_input: "" => "<computed>" 990 type: "" => "aws_instance" 991 992 STATE: 993 994 <no state> 995 ` 996 997 const testTerraformPlanModuleDestroyStr = ` 998 DIFF: 999 1000 DESTROY: aws_instance.foo 1001 1002 module.child: 1003 DESTROY MODULE 1004 DESTROY: aws_instance.foo 1005 1006 STATE: 1007 1008 aws_instance.foo: 1009 ID = bar 1010 1011 module.child: 1012 aws_instance.foo: 1013 ID = bar 1014 ` 1015 1016 const testTerraformPlanModuleDestroyCycleStr = ` 1017 DIFF: 1018 1019 module.a_module: 1020 DESTROY MODULE 1021 DESTROY: aws_instance.a 1022 module.b_module: 1023 DESTROY MODULE 1024 DESTROY: aws_instance.b 1025 1026 STATE: 1027 1028 module.a_module: 1029 aws_instance.a: 1030 ID = a 1031 module.b_module: 1032 aws_instance.b: 1033 ID = b 1034 ` 1035 1036 const testTerraformPlanModuleDestroyMultivarStr = ` 1037 DIFF: 1038 1039 module.child: 1040 DESTROY MODULE 1041 DESTROY: aws_instance.foo.0 1042 DESTROY: aws_instance.foo.1 1043 1044 STATE: 1045 1046 <no state> 1047 module.child: 1048 aws_instance.foo.0: 1049 ID = bar0 1050 aws_instance.foo.1: 1051 ID = bar1 1052 ` 1053 1054 const testTerraformPlanModuleInputStr = ` 1055 DIFF: 1056 1057 CREATE: aws_instance.bar 1058 foo: "" => "2" 1059 type: "" => "aws_instance" 1060 1061 module.child: 1062 CREATE: aws_instance.foo 1063 foo: "" => "42" 1064 type: "" => "aws_instance" 1065 1066 STATE: 1067 1068 <no state> 1069 ` 1070 1071 const testTerraformPlanModuleInputComputedStr = ` 1072 DIFF: 1073 1074 CREATE: aws_instance.bar 1075 foo: "" => "<computed>" 1076 type: "" => "aws_instance" 1077 1078 module.child: 1079 CREATE: aws_instance.foo 1080 foo: "" => "<computed>" 1081 type: "" => "aws_instance" 1082 1083 STATE: 1084 1085 <no state> 1086 ` 1087 1088 const testTerraformPlanModuleInputVarStr = ` 1089 DIFF: 1090 1091 CREATE: aws_instance.bar 1092 foo: "" => "2" 1093 type: "" => "aws_instance" 1094 1095 module.child: 1096 CREATE: aws_instance.foo 1097 foo: "" => "52" 1098 type: "" => "aws_instance" 1099 1100 STATE: 1101 1102 <no state> 1103 ` 1104 1105 const testTerraformPlanModuleMultiVarStr = ` 1106 DIFF: 1107 1108 CREATE: aws_instance.parent.0 1109 CREATE: aws_instance.parent.1 1110 1111 module.child: 1112 CREATE: aws_instance.bar.0 1113 baz: "" => "baz" 1114 type: "" => "aws_instance" 1115 CREATE: aws_instance.bar.1 1116 baz: "" => "baz" 1117 type: "" => "aws_instance" 1118 CREATE: aws_instance.foo 1119 foo: "" => "baz,baz" 1120 type: "" => "aws_instance" 1121 1122 STATE: 1123 1124 <no state> 1125 ` 1126 1127 const testTerraformPlanModuleOrphansStr = ` 1128 DIFF: 1129 1130 CREATE: aws_instance.foo 1131 num: "" => "2" 1132 type: "" => "aws_instance" 1133 1134 module.child: 1135 DESTROY: aws_instance.foo 1136 1137 STATE: 1138 1139 module.child: 1140 aws_instance.foo: 1141 ID = baz 1142 ` 1143 1144 const testTerraformPlanModuleVarStr = ` 1145 DIFF: 1146 1147 CREATE: aws_instance.bar 1148 foo: "" => "2" 1149 type: "" => "aws_instance" 1150 1151 module.child: 1152 CREATE: aws_instance.foo 1153 num: "" => "2" 1154 type: "" => "aws_instance" 1155 1156 STATE: 1157 1158 <no state> 1159 ` 1160 1161 const testTerraformPlanModuleVarComputedStr = ` 1162 DIFF: 1163 1164 CREATE: aws_instance.bar 1165 foo: "" => "<computed>" 1166 type: "" => "aws_instance" 1167 1168 module.child: 1169 CREATE: aws_instance.foo 1170 foo: "" => "<computed>" 1171 type: "" => "aws_instance" 1172 1173 STATE: 1174 1175 <no state> 1176 ` 1177 1178 const testTerraformPlanModuleVarIntStr = ` 1179 DIFF: 1180 1181 module.child: 1182 CREATE: aws_instance.foo 1183 num: "" => "2" 1184 type: "" => "aws_instance" 1185 1186 STATE: 1187 1188 <no state> 1189 ` 1190 1191 const testTerraformPlanOrphanStr = ` 1192 DIFF: 1193 1194 DESTROY: aws_instance.baz 1195 CREATE: aws_instance.foo 1196 num: "" => "2" 1197 type: "" => "aws_instance" 1198 1199 STATE: 1200 1201 aws_instance.baz: 1202 ID = bar 1203 ` 1204 1205 const testTerraformPlanStateStr = ` 1206 DIFF: 1207 1208 CREATE: aws_instance.bar 1209 foo: "" => "2" 1210 type: "" => "aws_instance" 1211 UPDATE: aws_instance.foo 1212 num: "" => "2" 1213 type: "" => "aws_instance" 1214 1215 STATE: 1216 1217 aws_instance.foo: 1218 ID = bar 1219 ` 1220 1221 const testTerraformPlanTaintStr = ` 1222 DIFF: 1223 1224 DESTROY/CREATE: aws_instance.bar 1225 foo: "" => "2" 1226 type: "" => "aws_instance" 1227 1228 STATE: 1229 1230 aws_instance.bar: (1 tainted) 1231 ID = <not created> 1232 Tainted ID 1 = baz 1233 aws_instance.foo: 1234 ID = bar 1235 num = 2 1236 ` 1237 1238 const testTerraformPlanMultipleTaintStr = ` 1239 DIFF: 1240 1241 DESTROY/CREATE: aws_instance.bar 1242 foo: "" => "2" 1243 type: "" => "aws_instance" 1244 1245 STATE: 1246 1247 aws_instance.bar: (2 tainted) 1248 ID = <not created> 1249 Tainted ID 1 = baz 1250 Tainted ID 2 = zip 1251 aws_instance.foo: 1252 ID = bar 1253 num = 2 1254 ` 1255 1256 const testTerraformPlanVarMultiCountOneStr = ` 1257 DIFF: 1258 1259 CREATE: aws_instance.bar 1260 foo: "" => "2" 1261 type: "" => "aws_instance" 1262 CREATE: aws_instance.foo 1263 num: "" => "2" 1264 type: "" => "aws_instance" 1265 1266 STATE: 1267 1268 <no state> 1269 ` 1270 1271 const testTerraformPlanPathVarStr = ` 1272 DIFF: 1273 1274 CREATE: aws_instance.foo 1275 cwd: "" => "%s/barpath" 1276 module: "" => "%s/foopath" 1277 root: "" => "%s/barpath" 1278 type: "" => "aws_instance" 1279 1280 STATE: 1281 1282 <no state> 1283 `