This repository has been archived by the owner on Aug 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ on: | |
|
||
jobs: | ||
build: | ||
name: build-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ on: | |
|
||
jobs: | ||
build: | ||
name: build-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Unit Tests | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
jobs: | ||
test_action_job: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.14 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14 | ||
- name: Check out source code | ||
uses: actions/checkout@v1 | ||
- name: Build | ||
env: | ||
GOPROXY: "https://proxy.golang.org" | ||
CGO_ENABLED: 0 | ||
GOOS: linux | ||
GOARCH: amd64 | ||
run: go build -a -installsuffix cgo -ldflags="-w -s" . | ||
- name: Test | ||
env: | ||
GOPROXY: "https://proxy.golang.org" | ||
CGO_ENABLED: 0 | ||
GOOS: linux | ||
GOARCH: amd64 | ||
LOG_LEVEL: DEBUG | ||
INPUT_CREDS: ${{ secrets.AZURE_CREDENTIALS }} | ||
INPUT_RESOURCEGROUPNAME: azurearmaction | ||
INPUT_TEMPLATELOCATION: ./test/template.json | ||
INPUT_PARAMETERSLOCATION: ./test/parameters.json | ||
INPUT_DEPLOYMENTNAME: github-test | ||
INPUT_DEPLOYMENTMODE: Incremental | ||
run: go test -v -failfast . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
sp.json | ||
arm-action | ||
__debug_bin | ||
__debug_bin | ||
run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
"LOG_LEVEL": "DEBUG" | ||
}, | ||
"args": [] | ||
} | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-05-01/resources" | ||
"github.com/Azure/go-autorest/autorest" | ||
"github.com/whiteducksoftware/azure-arm-action/pkg/github" | ||
"github.com/whiteducksoftware/azure-arm-action/pkg/github/actions" | ||
) | ||
|
||
var ( | ||
opts *github.Options | ||
authorizer *autorest.Authorizer | ||
deploymentResult resources.DeploymentExtended | ||
) | ||
|
||
func TestLoadOptions(t *testing.T) { | ||
var err error | ||
opts, err = github.LoadOptions() | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
} | ||
|
||
func TestAuthentication(t *testing.T) { | ||
var err error | ||
authorizer, err = actions.Authenticate(opts.Inputs) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
} | ||
|
||
func TestDeploy(t *testing.T) { | ||
var err error | ||
deploymentResult, err = actions.Deploy(context.Background(), opts.Inputs, authorizer) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
} | ||
|
||
func TestParseOutputs(t *testing.T) { | ||
outputs, err := actions.ParseOutputs(deploymentResult.Properties.Outputs) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
if len(outputs) != 2 { | ||
t.Errorf("Got invalid count of outputs, expected 2 got %d", len(outputs)) | ||
} | ||
|
||
// Test output key location | ||
value, ok := outputs["location"] | ||
if !ok { | ||
t.Errorf("Test key is missing in the outputs, exptected the key location to be present") | ||
} | ||
|
||
if value.Value != "westeurope" { | ||
t.Errorf("Got invalid value for location key, expected %s got %s", "westeurope", value.Value) | ||
} | ||
|
||
// Test output key containername | ||
value, ok = outputs["containerName"] | ||
if !ok { | ||
t.Errorf("Test key is missing in the outputs, exptected the key containerName to be present") | ||
} | ||
|
||
if value.Value != "github-action" { | ||
t.Errorf("Got invalid value for location key, expected %s got %s", "github-action", value.Value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters