- Notifications
You must be signed in to change notification settings - Fork22
Add metadata block to the agent#112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -71,7 +71,7 @@ func TestAgent(t *testing.T) { | ||
}) | ||
} | ||
funcTestAgent_Instance(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
Providers: map[string]*schema.Provider{ | ||
@@ -111,3 +111,49 @@ func TestAgentInstance(t *testing.T) { | ||
}}, | ||
}) | ||
} | ||
func TestAgent_Metadata(t *testing.T) { | ||
t.Parallel() | ||
resource.Test(t, resource.TestCase{ | ||
Providers: map[string]*schema.Provider{ | ||
"coder": provider.New(), | ||
}, | ||
IsUnitTest: true, | ||
Steps: []resource.TestStep{{ | ||
Config: ` | ||
provider "coder" { | ||
url = "https://example.com" | ||
} | ||
resource "coder_agent" "dev" { | ||
os = "linux" | ||
arch = "amd64" | ||
metadata { | ||
key = "process_count" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thoughts on calling this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We can make it id... We don't really want people thinking they have to auto generate it though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. In | ||
display_name = "Process Count" | ||
script = "ps aux | wc -l" | ||
interval = 5 | ||
timeout = 1 | ||
} | ||
} | ||
`, | ||
Check: func(state *terraform.State) error { | ||
require.Len(t, state.Modules, 1) | ||
require.Len(t, state.Modules[0].Resources, 1) | ||
resource := state.Modules[0].Resources["coder_agent.dev"] | ||
require.NotNil(t, resource) | ||
t.Logf("resource: %v", resource.Primary.Attributes) | ||
attr := resource.Primary.Attributes | ||
require.Equal(t, "1", attr["metadata.#"]) | ||
require.Equal(t, "process_count", attr["metadata.0.key"]) | ||
require.Equal(t, "Process Count", attr["metadata.0.display_name"]) | ||
require.Equal(t, "ps aux | wc -l", attr["metadata.0.script"]) | ||
require.Equal(t, "5", attr["metadata.0.interval"]) | ||
require.Equal(t, "1", attr["metadata.0.timeout"]) | ||
return nil | ||
}, | ||
}}, | ||
}) | ||
} |