本文整理匯總了Golang中bosh/assert.MatchesJsonString函數的典型用法代碼示例。如果您正苦於以下問題:Golang MatchesJsonString函數的具體用法?Golang MatchesJsonString怎麽用?Golang MatchesJsonString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MatchesJsonString函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestGetStateRunWithFullFormatOption
func TestGetStateRunWithFullFormatOption(t *testing.T) {
settings := &fakesettings.FakeSettingsService{}
settings.AgentId = "my-agent-id"
settings.Vm.Name = "vm-abc-def"
specService, jobSupervisor, fakeVitals, action := buildGetStateAction(settings)
jobSupervisor.StatusStatus = "running"
specService.Spec = boshas.V1ApplySpec{
Deployment: "fake-deployment",
}
expectedVitals := boshvitals.Vitals{
Load: []string{"foo", "bar", "baz"},
}
fakeVitals.GetVitals = expectedVitals
expectedVm := map[string]interface{}{"name": "vm-abc-def"}
state, err := action.Run("full")
assert.NoError(t, err)
boshassert.MatchesJsonString(t, state.AgentId, `"my-agent-id"`)
boshassert.MatchesJsonString(t, state.JobState, `"running"`)
boshassert.MatchesJsonString(t, state.Deployment, `"fake-deployment"`)
assert.Equal(t, *state.Vitals, expectedVitals)
boshassert.MatchesJsonMap(t, state.Vm, expectedVm)
}
示例2: init
func init() {
Describe("Testing with Ginkgo", func() {
It("mount disk should be asynchronous", func() {
settings := &fakesettings.FakeSettingsService{}
_, action := buildMountDiskAction(settings)
Expect(action.IsAsynchronous()).To(BeTrue())
})
It("is not persistent", func() {
settings := &fakesettings.FakeSettingsService{}
_, action := buildMountDiskAction(settings)
Expect(action.IsPersistent()).To(BeFalse())
})
It("mount disk", func() {
settings := &fakesettings.FakeSettingsService{}
settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
platform, mountDisk := buildMountDiskAction(settings)
result, err := mountDisk.Run("vol-123")
Expect(err).NotTo(HaveOccurred())
boshassert.MatchesJsonString(GinkgoT(), result, "{}")
Expect(settings.SettingsWereLoaded).To(BeTrue())
Expect(platform.MountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
Expect(platform.MountPersistentDiskMountPoint).To(Equal("/foo/store"))
})
It("mount disk when store already mounted", func() {
settings := &fakesettings.FakeSettingsService{}
settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
platform, mountDisk := buildMountDiskAction(settings)
platform.IsMountPointResult = true
result, err := mountDisk.Run("vol-123")
Expect(err).NotTo(HaveOccurred())
boshassert.MatchesJsonString(GinkgoT(), result, "{}")
Expect(platform.IsMountPointPath).To(Equal("/foo/store"))
Expect(platform.MountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
Expect(platform.MountPersistentDiskMountPoint).To(Equal("/foo/store_migration_target"))
})
It("mount disk when device path not found", func() {
settings := &fakesettings.FakeSettingsService{}
settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
_, mountDisk := buildMountDiskAction(settings)
_, err := mountDisk.Run("vol-456")
Expect(err).To(HaveOccurred())
})
})
}
示例3: init
func init() {
Describe("Testing with Ginkgo", func() {
It("json with value", func() {
resp := NewValueResponse("some value")
boshassert.MatchesJsonString(GinkgoT(), resp, `{"value":"some value"}`)
})
It("json with exception", func() {
resp := NewExceptionResponse("oops!")
boshassert.MatchesJsonString(GinkgoT(), resp, `{"exception":{"message":"oops!"}}`)
})
})
}
示例4: init
func init() {
Describe("Testing with Ginkgo", func() {
It("mount disk should be asynchronous", func() {
settings := &fakesettings.FakeSettingsService{}
_, action := buildMountDiskAction(settings)
assert.True(GinkgoT(), action.IsAsynchronous())
})
It("mount disk", func() {
settings := &fakesettings.FakeSettingsService{}
settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
platform, mountDisk := buildMountDiskAction(settings)
result, err := mountDisk.Run("vol-123")
assert.NoError(GinkgoT(), err)
boshassert.MatchesJsonString(GinkgoT(), result, "{}")
assert.True(GinkgoT(), settings.SettingsWereRefreshed)
assert.Equal(GinkgoT(), platform.MountPersistentDiskDevicePath, "/dev/sdf")
assert.Equal(GinkgoT(), platform.MountPersistentDiskMountPoint, "/foo/store")
})
It("mount disk when store already mounted", func() {
settings := &fakesettings.FakeSettingsService{}
settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
platform, mountDisk := buildMountDiskAction(settings)
platform.IsMountPointResult = true
result, err := mountDisk.Run("vol-123")
assert.NoError(GinkgoT(), err)
boshassert.MatchesJsonString(GinkgoT(), result, "{}")
assert.Equal(GinkgoT(), platform.IsMountPointPath, "/foo/store")
assert.Equal(GinkgoT(), platform.MountPersistentDiskDevicePath, "/dev/sdf")
assert.Equal(GinkgoT(), platform.MountPersistentDiskMountPoint, "/foo/store_migration_target")
})
It("mount disk when device path not found", func() {
settings := &fakesettings.FakeSettingsService{}
settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
_, mountDisk := buildMountDiskAction(settings)
_, err := mountDisk.Run("vol-456")
assert.Error(GinkgoT(), err)
})
})
}
示例5: init
func init() {
Describe("Testing with Ginkgo", func() {
It("unmount disk should be asynchronous", func() {
platform := fakeplatform.NewFakePlatform()
action := buildUnmountDiskAction(platform)
Expect(action.IsAsynchronous()).To(BeTrue())
})
It("is not persistent", func() {
platform := fakeplatform.NewFakePlatform()
action := buildUnmountDiskAction(platform)
Expect(action.IsPersistent()).To(BeFalse())
})
It("unmount disk when the disk is mounted", func() {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = true
unmountDisk := buildUnmountDiskAction(platform)
result, err := unmountDisk.Run("vol-123")
Expect(err).ToNot(HaveOccurred())
boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Unmounted partition of /dev/sdf"}`)
Expect(platform.UnmountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
})
It("unmount disk when the disk is not mounted", func() {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = false
mountDisk := buildUnmountDiskAction(platform)
result, err := mountDisk.Run("vol-123")
Expect(err).ToNot(HaveOccurred())
boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Partition of /dev/sdf is not mounted"}`)
Expect(platform.UnmountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
})
It("unmount disk when device path not found", func() {
platform := fakeplatform.NewFakePlatform()
mountDisk := buildUnmountDiskAction(platform)
_, err := mountDisk.Run("vol-456")
Expect(err).To(HaveOccurred())
})
})
}
示例6: assertRequestIsProcessedSynchronously
func assertRequestIsProcessedSynchronously(t *testing.T, req boshmbus.Request) {
settings, handler, platform, taskService, actionFactory := getAgentDependencies()
// when action is successful
actionFactory.CreateAction = &fakeaction.TestAction{
RunValue: "some value",
}
agent := New(settings, handler, platform, taskService, actionFactory)
err := agent.Run()
assert.NoError(t, err)
assert.True(t, handler.ReceivedRun)
resp := handler.Func(req)
assert.Equal(t, req.Method, actionFactory.CreateMethod)
assert.Equal(t, req.GetPayload(), actionFactory.CreateAction.RunPayload)
assert.Equal(t, boshmbus.NewValueResponse("some value"), resp)
// when action returns an error
actionFactory.CreateAction = &fakeaction.TestAction{
RunErr: errors.New("some error"),
}
agent = New(settings, handler, platform, taskService, actionFactory)
agent.Run()
resp = handler.Func(req)
boshassert.MatchesJsonString(t, resp, `{"exception":{"message":"some error"}}`)
}
示例7: init
func init() {
Describe("Testing with Ginkgo", func() {
It("list disk should be synchronous", func() {
settings := &fakesettings.FakeSettingsService{}
platform := fakeplatform.NewFakePlatform()
action := NewListDisk(settings, platform)
assert.False(GinkgoT(), action.IsAsynchronous())
})
It("list disk run", func() {
settings := &fakesettings.FakeSettingsService{
Disks: boshsettings.Disks{
Persistent: map[string]string{
"volume-1": "/dev/sda",
"volume-2": "/dev/sdb",
"volume-3": "/dev/sdc",
},
},
}
platform := fakeplatform.NewFakePlatform()
platform.MountedDevicePaths = []string{"/dev/sdb", "/dev/sdc"}
action := NewListDisk(settings, platform)
value, err := action.Run()
assert.NoError(GinkgoT(), err)
boshassert.MatchesJsonString(GinkgoT(), value, `["volume-2","volume-3"]`)
})
})
}
示例8: testLogs
func testLogs(t assert.TestingT, logType string, filters []string, expectedFilters []string) {
deps, action := buildLogsAction()
deps.copier.FilteredCopyToTempTempDir = "/fake-temp-dir"
deps.compressor.CompressFilesInDirTarballPath = "logs_test.go"
deps.blobstore.CreateBlobId = "my-blob-id"
logs, err := action.Run(logType, filters)
assert.NoError(t, err)
var expectedPath string
switch logType {
case "job":
expectedPath = filepath.Join("/fake", "dir", "sys", "log")
case "agent":
expectedPath = filepath.Join("/fake", "dir", "bosh", "log")
}
assert.Equal(t, expectedPath, deps.copier.FilteredCopyToTempDir)
assert.Equal(t, expectedFilters, deps.copier.FilteredCopyToTempFilters)
assert.Equal(t, deps.copier.FilteredCopyToTempTempDir, deps.compressor.CompressFilesInDirDir)
assert.Equal(t, deps.copier.CleanUpTempDir, deps.compressor.CompressFilesInDirDir)
assert.Equal(t, deps.compressor.CompressFilesInDirTarballPath, deps.blobstore.CreateFileName)
boshassert.MatchesJsonString(t, logs, `{"blobstore_id":"my-blob-id"}`)
}
示例9: init
func init() {
Describe("Testing with Ginkgo", func() {
It("migrate disk should be asynchronous", func() {
_, action := buildMigrateDiskAction()
Expect(action.IsAsynchronous()).To(BeTrue())
})
It("is not persistent", func() {
_, action := buildMigrateDiskAction()
Expect(action.IsPersistent()).To(BeFalse())
})
It("migrate disk action run", func() {
platform, action := buildMigrateDiskAction()
value, err := action.Run()
Expect(err).ToNot(HaveOccurred())
boshassert.MatchesJsonString(GinkgoT(), value, "{}")
Expect(platform.MigratePersistentDiskFromMountPoint).To(Equal("/foo/store"))
Expect(platform.MigratePersistentDiskToMountPoint).To(Equal("/foo/store_migration_target"))
})
})
}
示例10: init
func init() {
Describe("Testing with Ginkgo", func() {
It("get", func() {
fs, specPath, service := buildV1Service()
fs.WriteToFile(specPath, `{"deployment":"fake-deployment-name"}`)
spec, err := service.Get()
assert.NoError(GinkgoT(), err)
expectedSpec := V1ApplySpec{
Deployment: "fake-deployment-name",
}
assert.Equal(GinkgoT(), expectedSpec, spec)
})
It("set", func() {
fs, specPath, service := buildV1Service()
spec := V1ApplySpec{
JobSpec: JobSpec{
Name: "fake-job",
},
}
err := service.Set(spec)
assert.NoError(GinkgoT(), err)
specPathStats := fs.GetFileTestStat(specPath)
assert.NotNil(GinkgoT(), specPathStats)
boshassert.MatchesJsonString(GinkgoT(), spec, specPathStats.Content)
})
})
}
示例11: TestMigrateDiskActionRun
func TestMigrateDiskActionRun(t *testing.T) {
platform, action := buildMigrateDiskAction()
value, err := action.Run()
assert.NoError(t, err)
boshassert.MatchesJsonString(t, value, "{}")
assert.Equal(t, platform.MigratePersistentDiskFromMountPoint, "/foo/store")
assert.Equal(t, platform.MigratePersistentDiskToMountPoint, "/foo/store_migration_target")
}
示例12: init
func init() {
Describe("Testing with Ginkgo", func() {
It("unmount disk should be asynchronous", func() {
platform := fakeplatform.NewFakePlatform()
action := buildUnmountDiskAction(platform)
assert.True(GinkgoT(), action.IsAsynchronous())
})
It("unmount disk when the disk is mounted", func() {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = true
unmountDisk := buildUnmountDiskAction(platform)
result, err := unmountDisk.Run("vol-123")
assert.NoError(GinkgoT(), err)
boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Unmounted partition of /dev/sdf"}`)
assert.Equal(GinkgoT(), platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
})
It("unmount disk when the disk is not mounted", func() {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = false
mountDisk := buildUnmountDiskAction(platform)
result, err := mountDisk.Run("vol-123")
assert.NoError(GinkgoT(), err)
boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Partition of /dev/sdf is not mounted"}`)
assert.Equal(GinkgoT(), platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
})
It("unmount disk when device path not found", func() {
platform := fakeplatform.NewFakePlatform()
mountDisk := buildUnmountDiskAction(platform)
_, err := mountDisk.Run("vol-456")
assert.Error(GinkgoT(), err)
})
})
}
示例13: TestUnmountDiskWhenTheDiskIsNotMounted
func TestUnmountDiskWhenTheDiskIsNotMounted(t *testing.T) {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = false
mountDisk := buildUnmountDiskAction(platform)
result, err := mountDisk.Run("vol-123")
assert.NoError(t, err)
boshassert.MatchesJsonString(t, result, `{"message":"Partition of /dev/sdf is not mounted"}`)
assert.Equal(t, platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
}
示例14: TestUnmountDiskWhenTheDiskIsMounted
func TestUnmountDiskWhenTheDiskIsMounted(t *testing.T) {
platform := fakeplatform.NewFakePlatform()
platform.UnmountPersistentDiskDidUnmount = true
unmountDisk := buildUnmountDiskAction(platform)
payload := `{"arguments":["vol-123"]}`
result, err := unmountDisk.Run([]byte(payload))
assert.NoError(t, err)
boshassert.MatchesJsonString(t, result, `{"message":"Unmounted partition of /dev/sdf"}`)
assert.Equal(t, platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
}
示例15: TestDispatchRespondsWithExceptionWhenTheMethodIsUnknown
func TestDispatchRespondsWithExceptionWhenTheMethodIsUnknown(t *testing.T) {
logger, taskService, actionFactory, actionRunner := getActionDispatcherDependencies()
req := boshhandler.NewRequest("reply to me", "gibberish", []byte{})
actionFactory.CreateErr = true
dispatcher := NewActionDispatcher(logger, taskService, actionFactory, actionRunner)
resp := dispatcher.Dispatch(req)
boshassert.MatchesJsonString(t, resp, `{"exception":{"message":"unknown message gibberish"}}`)
assert.Equal(t, actionFactory.CreateMethod, "gibberish")
}