Skip to content

Commit

Permalink
refactor examples for new build process (#112)
Browse files Browse the repository at this point in the history
* refactor examples for new build process

* go fmt/fgo imports
  • Loading branch information
jaxxstorm committed Jun 10, 2020
1 parent dc3dbc0 commit 4f5efb7
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 58 deletions.
31 changes: 31 additions & 0 deletions examples/examples_dotnet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed 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.
// +build dotnet all

package examples

import (
"testing"

"github.com/pulumi/pulumi/pkg/v2/testing/integration"
)

func getCsharpBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions()
baseCsharp := base.With(integration.ProgramTestOptions{
Dependencies: []string{
"Pulumi.SpotInst",
},
})

return baseCsharp
}
78 changes: 78 additions & 0 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Licensed 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.
// +build nodejs all

package examples

import (
"path"
"testing"

"github.com/pulumi/pulumi/pkg/v2/testing/integration"
)

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
checkDigitalOceanTokenSet(t)
base := getBaseOptions()
baseJS := base.With(integration.ProgramTestOptions{
Dependencies: []string{
"@pulumi/digitalocean",
},
})

return baseJS
}

func TestAccDatabaseCluster(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "databaseCluster"),
})

integration.ProgramTest(t, &test)
}

func TestAccDomain(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "domain"),
})

integration.ProgramTest(t, &test)
}

func TestAccDroplet(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "droplet"),
})

integration.ProgramTest(t, &test)
}

func TestAccFloatingIp(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "floatingip"),
})

integration.ProgramTest(t, &test)
}

func TestAccLoadbalancer(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "loadbalancer"),
})

integration.ProgramTest(t, &test)
}
32 changes: 32 additions & 0 deletions examples/examples_py_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed 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.
// +build python all

package examples

import (
"path/filepath"
"testing"

"github.com/pulumi/pulumi/pkg/v2/testing/integration"
)

func getPythonBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions()
basePython := base.With(integration.ProgramTestOptions{
Dependencies: []string{
filepath.Join("..", "sdk", "python", "bin"),
},
})

return basePython
}
58 changes: 0 additions & 58 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,11 @@ package examples

import (
"os"
"path"
"testing"

"github.com/pulumi/pulumi/pkg/v2/testing/integration"
)

func TestAccDatabaseCluster(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "databaseCluster"),
})

integration.ProgramTest(t, &test)
}

func TestAccDomain(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "domain"),
})

integration.ProgramTest(t, &test)
}

func TestAccDroplet(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "droplet"),
})

integration.ProgramTest(t, &test)
}

func TestAccFloatingIp(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "floatingip"),
})

integration.ProgramTest(t, &test)
}

func TestAccLoadbalancer(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "loadbalancer"),
})

integration.ProgramTest(t, &test)
}

func checkDigitalOceanTokenSet(t *testing.T) {
token := os.Getenv("DIGITALOCEAN_TOKEN")
if token == "" {
Expand All @@ -86,15 +40,3 @@ func getBaseOptions() integration.ProgramTestOptions {
ExpectRefreshChanges: true,
}
}

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
checkDigitalOceanTokenSet(t)
base := getBaseOptions()
baseJS := base.With(integration.ProgramTestOptions{
Dependencies: []string{
"@pulumi/digitalocean",
},
})

return baseJS
}

0 comments on commit 4f5efb7

Please sign in to comment.