core: Fix TestContext2Apply_unstable

We now handle impure functions by having them return an unknown value
during plan, since we can't predict what the value will be during apply.
This test was assuming the old behavior.
This commit is contained in:
Martin Atkins 2018-09-06 16:54:33 -07:00
parent ee49be73be
commit a7f948ab90
1 changed files with 9 additions and 8 deletions

View File

@ -102,8 +102,9 @@ func TestContext2Apply_unstable(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
randomVal := rd.After.GetAttr("random").AsString() if rd.After.GetAttr("random").IsKnown() {
t.Logf("plan-time value is %q", randomVal) t.Fatalf("Attribute 'random' has known value %#v; should be unknown in plan", rd.After.GetAttr("random"))
}
state, diags := ctx.Apply() state, diags := ctx.Apply()
if diags.HasErrors() { if diags.HasErrors() {
@ -118,12 +119,12 @@ func TestContext2Apply_unstable(t *testing.T) {
} }
rs, err := rss.Current.Decode(schema.ImpliedType()) rs, err := rss.Current.Decode(schema.ImpliedType())
if got, want := rs.Value.GetAttr("random").AsString(), randomVal; got != want { got := rs.Value.GetAttr("random")
// FIXME: We actually currently have a bug where we re-interpolate if !got.IsKnown() {
// the config during apply and end up with a random result, so this t.Fatalf("random is still unknown after apply")
// check fails. This check _should not_ fail, so we should fix this }
// up in a later release. if got, want := len(got.AsString()), 1; got != want {
//t.Errorf("wrong random value %q; want %q", got, want) t.Fatalf("random string has wrong length %d; want %d", got, want)
} }
} }