Skip to content

Instantly share code, notes, and snippets.

@selmanj
Created September 26, 2017 00:55
Show Gist options
  • Save selmanj/938dc78915c116089849b4a686174078 to your computer and use it in GitHub Desktop.
Save selmanj/938dc78915c116089849b4a686174078 to your computer and use it in GitHub Desktop.
package foo
func TestMyQueueWorker(t *testing.T) {
state, err := terraform.Apply(fmt.Sprintf(`
resource "google_pubsub_topic" "in-topic" {
name = "acc-test-%s"
}
resource "google_pubsub_subscription" "in-topic-sub" {
name = "acc-test-%s"
topic = "${google_pubsub_topic.topic.name}"
# Set this to a large value for integration tests
ack_deadline_seconds = 3600
}
resource "google_storage_bucket" "output-bucket" {
name = "acc-test-%s"
}`, tools.RandString(8), tools.RandString(8), tools.RandString(8)))
if err != nil {
t.Error(err)
}
defer state.Destroy()
config := myapp.Config{
Topic: state.Interpolate("google_pubsub_subscription.in-topic-sub.name"),
OutputBucket: state.Interpolate("google_storage_bucket.output-bucket.name"),
}
// Error ignored for brevity
app, _ = myApp.Start(config)
app.Join()
// Ensure output looks right
apptest.AssertOutput(config.OutputBucket)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment