コード例 #1
0
func TestAccLogentriesLogSet_NoLocation(t *testing.T) {
	var logSetResource LogSetResource

	logSetName := fmt.Sprintf("terraform-test-%s", acctest.RandString(8))
	testAccLogentriesLogSetConfig := fmt.Sprintf(`
		resource "logentries_logset" "test_logset" {
			name = "%s"
		}
	`, logSetName)

	resource.Test(t, resource.TestCase{
		PreCheck:     func() { testAccPreCheck(t) },
		Providers:    testAccProviders,
		CheckDestroy: testAccCheckLogentriesLogSetDestroy,
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccLogentriesLogSetConfig,
				Check: lexp.TestCheckResourceExpectation(
					"logentries_logset.test_logset",
					&logSetResource,
					testAccCheckLogentriesLogSetExists,
					map[string]lexp.TestExpectValue{
						"name":     lexp.Equals(logSetName),
						"location": lexp.Equals("nonlocation"),
					},
				),
			},
		},
	})
}
コード例 #2
0
func TestAccLogentriesLog_SourceAgent(t *testing.T) {
	var logResource LogResource

	logName := fmt.Sprintf("terraform-test-%s", acctest.RandString(8))
	fileName := "/opt/foo"
	testAccLogentriesLogConfig := fmt.Sprintf(`
		resource "logentries_logset" "test_logset" {
			name = "%s"
		}
		resource "logentries_log" "test_log" {
			logset_id = "${logentries_logset.test_logset.id}"
			name = "%s"
			source = "agent"
			filename = "%s"
		}
	`, logName, logName, fileName)

	resource.Test(t, resource.TestCase{
		PreCheck:  func() { testAccPreCheck(t) },
		Providers: testAccProviders,
		CheckDestroy: func(s *terraform.State) error {
			testAccCheckLogentriesLogDestroy(s)
			testAccCheckLogentriesLogSetDestroy(s)
			return nil
		},
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccLogentriesLogConfig,
				Check: lexp.TestCheckResourceExpectation(
					"logentries_log.test_log",
					&logResource,
					testAccCheckLogentriesLogExists,
					map[string]lexp.TestExpectValue{
						"name":     lexp.Equals(logName),
						"source":   lexp.Equals("agent"),
						"filename": lexp.Equals(fileName),
					},
				),
			},
		},
	})
}
コード例 #3
0
func TestAccLogentriesLog_RetentionPeriodAccountUnlimited(t *testing.T) {
	var logResource LogResource

	logName := fmt.Sprintf("terraform-test-%s", acctest.RandString(8))
	testAccLogentriesLogConfig := fmt.Sprintf(`
		resource "logentries_logset" "test_logset" {
			name = "%s"
		}
		resource "logentries_log" "test_log" {
			logset_id = "${logentries_logset.test_logset.id}"
			name = "%s"
			retention_period = "UNLIMITED"
		}
	`, logName, logName)

	resource.Test(t, resource.TestCase{
		PreCheck:  func() { testAccPreCheck(t) },
		Providers: testAccProviders,
		CheckDestroy: func(s *terraform.State) error {
			testAccCheckLogentriesLogDestroy(s)
			testAccCheckLogentriesLogSetDestroy(s)
			return nil
		},
		Steps: []resource.TestStep{
			resource.TestStep{
				Config: testAccLogentriesLogConfig,
				Check: lexp.TestCheckResourceExpectation(
					"logentries_log.test_log",
					&logResource,
					testAccCheckLogentriesLogExists,
					map[string]lexp.TestExpectValue{
						"name":             lexp.Equals(logName),
						"retention_period": lexp.Equals("UNLIMITED"),
					},
				),
			},
		},
	})
}