blob: e27b1e140dac7ec4ed9c54384f575f87f7130c0a [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
package cloudstack
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
//basic acceptance to check if the display_name attribute has same value in
//the created instance and its data source respectively.
func TestAccInstanceDataSource_basic(t *testing.T) {
resourceName := "cloudstack_instance.my_instance"
datasourceName := "data.cloudstack_instance.my_instance_test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccInstanceDataSourceConfig_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(datasourceName, "display_name", resourceName, "display_name"),
),
ExpectNonEmptyPlan: true,
},
},
})
}
const testAccInstanceDataSourceConfig_basic = `
resource "cloudstack_instance" "my_instance" {
name = "server-a"
service_offering = "Small Instance"
network_id = "b9c953a0-8686-4240-b8a4-43849f7079ff"
template = "CentOS 5.5(64-bit) no GUI (KVM)"
zone = "DC"
}
data "cloudstack_instance" "my_instance_test" {
filter {
name = "display_name"
value = "server-a"
}
depends_on = [
cloudstack_instance.my_instance
]
}
`