Exemple #1
0
					      "resource_id",
					      "tenant0"
					    );
					  });`,
					"path": ".*",
				})
				Expect(err).ToNot(HaveOccurred())
				extensions := []*schema.Extension{extension}
				env := otto.NewEnvironment(testDB, &middleware.FakeIdentity{}, timelimit)
				Expect(env.LoadExtensionsForPath(extensions, "test_path")).To(Succeed())

				manager := schema.GetManager()
				s, ok := manager.Schema("test")
				Expect(ok).To(BeTrue())

				var fakeTx = new(mocks.Transaction)
				fakeTx.On(
					"StateFetch", s, "resource_id", []string{"tenant0"},
				).Return(
					transaction.ResourceState{
						ConfigVersion: 30,
						StateVersion:  29,
						Error:         "e",
						State:         "s",
						Monitoring:    "m",
					},
					nil,
				)

				context := map[string]interface{}{
					"transaction": fakeTx,
Exemple #2
0
					"code": `
					  gohan_register_handler("test_event", function(context){
					    var tx = context.transaction;
					    context.resp = gohan_db_list(
					      tx,
					      "test",
					      {"tenant_id": "tenant0"}
					    );
					  });`,
					"path": ".*",
				})
				Expect(err).ToNot(HaveOccurred())
				env := newEnvironmentWithExtension(extension)

				var pagenator *pagination.Paginator
				var fakeTx = new(mocks.Transaction)
				fakeTx.On(
					"List", s, transaction.Filter{"tenant_id": "tenant0"}, pagenator,
				).Return(
					[]*schema.Resource{r0, r1},
					uint64(2),
					nil,
				)

				context := map[string]interface{}{
					"transaction": fakeTx,
				}
				Expect(env.HandleEvent("test_event", context)).To(Succeed())

				Expect(context["resp"]).To(
					Equal(
Exemple #3
0
				manager := schema.GetManager()
				s, ok := manager.Schema("test")
				Expect(ok).To(BeTrue())

				fakeResources := []map[string]interface{}{
					map[string]interface{}{"tenant_id": "t0", "test_string": "str0"},
					map[string]interface{}{"tenant_id": "t1", "test_string": "str1"},
				}

				r0, err := schema.NewResource(s, fakeResources[0])
				Expect(err).ToNot(HaveOccurred())
				r1, err := schema.NewResource(s, fakeResources[1])
				Expect(err).ToNot(HaveOccurred())

				var fakeTx = new(mocks.Transaction)
				fakeTx.On(
					"Query", s, "SELECT DUMMY", []interface{}{"tenant0", "obj1"},
				).Return(
					[]*schema.Resource{r0, r1}, nil,
				)

				context := map[string]interface{}{
					"transaction": fakeTx,
				}
				Expect(env.HandleEvent("test_event", context)).To(Succeed())
				Expect(context["resp"]).To(Equal(fakeResources))
			})
		})

		Context("When an invalid transaction is provided", func() {