(t *testing.T)
| 1602 | } |
| 1603 | |
| 1604 | func TestEnvExtension(t *testing.T) { |
| 1605 | env := testEnv(t, |
| 1606 | Container("google.api.expr.v1alpha1"), |
| 1607 | Types(&exprpb.Expr{}), |
| 1608 | Variable("expr", ObjectType("google.api.expr.v1alpha1.Expr")), |
| 1609 | Variable("m", MapType(TypeParamType("K"), TypeParamType("V"))), |
| 1610 | OptionalTypes(), |
| 1611 | ) |
| 1612 | e2, err := env.Extend( |
| 1613 | CustomTypeAdapter(types.DefaultTypeAdapter), |
| 1614 | Types(&proto3pb.TestAllTypes{}), |
| 1615 | OptionalTypes(), |
| 1616 | OptionalTypes(), |
| 1617 | OptionalTypes(), |
| 1618 | ) |
| 1619 | if err != nil { |
| 1620 | t.Fatalf("env.Extend() failed: %v", err) |
| 1621 | } |
| 1622 | if env == e2 { |
| 1623 | t.Error("got object equality, wanted separate objects") |
| 1624 | } |
| 1625 | if env.TypeAdapter() == e2.TypeAdapter() { |
| 1626 | t.Error("got the same type adapter, wanted isolated instances.") |
| 1627 | } |
| 1628 | if env.TypeProvider() == e2.TypeProvider() { |
| 1629 | t.Error("got the same type provider, wanted isolated instances.") |
| 1630 | } |
| 1631 | e3, err := e2.Extend(OptionalTypes()) |
| 1632 | if err != nil { |
| 1633 | t.Fatalf("env.Extend() failed: %v", err) |
| 1634 | } |
| 1635 | if e2.TypeAdapter() != e3.TypeAdapter() { |
| 1636 | t.Error("got different type adapters, wanted immutable adapter reference") |
| 1637 | } |
| 1638 | if e2.TypeProvider() == e3.TypeProvider() { |
| 1639 | t.Error("got the same type provider, wanted isolated instances.") |
| 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | func TestEnvExtensionIsolation(t *testing.T) { |
| 1644 | baseEnv := testEnv(t, |
nothing calls this directly
no test coverage detected