-
Notifications
You must be signed in to change notification settings - Fork 22
Add data source attribute for owner email address #31
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,10 @@ func TestProvider(t *testing.T) { | |
} | ||
|
||
func TestWorkspace(t *testing.T) { | ||
t.Parallel() | ||
t.Setenv("CODER_WORKSPACE_OWNER", "owner123") | ||
t.Setenv("CODER_WORKSPACE_OWNER_NAME", "Workspace Owner Jr.") | ||
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. I kinda messed this up in the other issue, and I think it could be better to remove this for now. Since we don't have a display name, it could be easy to confuse 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. Sure. I was thinking it would be convenient to have a separate variable, because in the future we'll probably be able to get a display name from e.g. an OIDC provider. But you're right that for now, it's potentially confusing. 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. That's a good idea to expose the attributes. Interesting |
||
t.Setenv("CODER_WORKSPACE_OWNER_EMAIL", "[email protected]") | ||
|
||
resource.Test(t, resource.TestCase{ | ||
Providers: map[string]*schema.Provider{ | ||
"coder": provider.New(), | ||
|
@@ -37,9 +40,14 @@ func TestWorkspace(t *testing.T) { | |
require.Len(t, state.Modules[0].Resources, 1) | ||
resource := state.Modules[0].Resources["data.coder_workspace.me"] | ||
require.NotNil(t, resource) | ||
value := resource.Primary.Attributes["transition"] | ||
|
||
attribs := resource.Primary.Attributes | ||
value := attribs["transition"] | ||
require.NotNil(t, value) | ||
t.Log(value) | ||
require.Equal(t, "owner123", attribs["owner"]) | ||
require.Equal(t, "Workspace Owner Jr.", attribs["owner_name"]) | ||
require.Equal(t, "[email protected]", attribs["owner_email"]) | ||
return nil | ||
}, | ||
}}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other attributes handled by this function all have a non-empty default value in case the expected environment var is missing. But I can't think of a good default for the email address, and in my testing, there didn't seem to be any problem with leaving it empty.