Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions tests/ginkgo/temp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ginkgo

import (
"path"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/replicatedcom/support-bundle/cmd"
)

var _ = Describe("Checking contents of the file", func() {

BeforeEach(EnterNewTempDir)
AfterEach(CleanupDir)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these ginkgo builtins?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, looks like they're in helpers.go

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe, BeforeEach & AfterEach are, CleanupDir is what Dex wrote


It("Validating text in blah.txt", func() {

WriteFile("blah.txt", `
Hey there!
Let's take a peek into my file!`)

Copy link
Copy Markdown
Contributor

@laverya laverya Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like searching the source file itself for some random nonce, with the random nonce only on the search line like this: Expect(contents).To(ContainSubstring("MBkQAZ93qN"))

But that's really arcane and probably an antipattern.

WriteFile("config.yml", `
specs:
- builtin: core.read-file
raw: /daemon/etc/default/replicated
config:
file_path: blah.txt
`)

err := cmd.Generate(
path.Join(tmpdir, "config.yml"),
path.Join(tmpdir, "bundle.tar.gz"),
true,
60,
)

Expect(err).To(BeNil())

contents := ReadFileFromBundle(
path.Join("bundle.tar.gz"),
"/daemon/etc/default/replicated",
)
Expect(contents).To(ContainSubstring("Hey there!"))
Expect(contents).To(ContainSubstring("Let's take a peek into my file!"))

})

})