Skip to content

Commit eba3d12

Browse files
committed
tests!
1 parent eaddb5b commit eba3d12

7 files changed

+427
-2
lines changed

provisioner/terraform/resources.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,17 +704,21 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
704704
if resource.Type != "coder_external_auth" && resource.Type != "coder_git_auth" {
705705
continue
706706
}
707+
707708
id, ok := resource.AttributeValues["id"].(string)
708709
if !ok {
709710
return nil, xerrors.Errorf("external auth id is not a string")
710711
}
711-
712712
optional := false
713713
optionalAttribute, ok := resource.AttributeValues["optional"].(bool)
714714
if ok {
715715
optional = optionalAttribute
716716
}
717-
externalAuthProvidersMap[id] = &proto.ExternalAuthProviderResource{Optional: optional}
717+
718+
externalAuthProvidersMap[id] = &proto.ExternalAuthProviderResource{
719+
Id: id,
720+
Optional: optional,
721+
}
718722
}
719723
}
720724
externalAuthProviders := make([]*proto.ExternalAuthProviderResource, 0, len(externalAuthProvidersMap))

provisioner/terraform/resources_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,21 @@ func TestConvertResources(t *testing.T) {
489489
}},
490490
externalAuthProviders: []*proto.ExternalAuthProviderResource{{Id: "github"}, {Id: "gitlab"}},
491491
},
492+
"external-auth-providers": {
493+
resources: []*proto.Resource{{
494+
Name: "dev",
495+
Type: "null_resource",
496+
Agents: []*proto.Agent{{
497+
Name: "main",
498+
OperatingSystem: "linux",
499+
Architecture: "amd64",
500+
Auth: &proto.Agent_Token{},
501+
ConnectionTimeoutSeconds: 120,
502+
DisplayApps: &displayApps,
503+
}},
504+
}},
505+
externalAuthProviders: []*proto.ExternalAuthProviderResource{{Id: "github"}, {Id: "gitlab", Optional: true}},
506+
},
492507
"display-apps": {
493508
resources: []*proto.Resource{{
494509
Name: "dev",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
terraform {
2+
required_providers {
3+
coder = {
4+
source = "mckayla.dev/coder/coder"
5+
version = "1.0.0"
6+
# source = "coder/coder"
7+
# version = "0.6.13"
8+
}
9+
}
10+
}
11+
12+
data "coder_external_auth" "github" {
13+
id = "github"
14+
}
15+
16+
data "coder_external_auth" "gitlab" {
17+
id = "gitlab"
18+
optional = true
19+
}
20+
21+
resource "coder_agent" "main" {
22+
os = "linux"
23+
arch = "amd64"
24+
}
25+
26+
resource "null_resource" "dev" {
27+
depends_on = [
28+
coder_agent.main
29+
]
30+
}

provisioner/terraform/testdata/external-auth-providers/external-auth-providers.tfplan.dot

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisioner/terraform/testdata/external-auth-providers/external-auth-providers.tfplan.json

Lines changed: 230 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisioner/terraform/testdata/external-auth-providers/external-auth-providers.tfstate.dot

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)