Skip to content
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

dedupe #143

Merged
merged 1 commit into from Jun 2, 2020
Merged

dedupe #143

merged 1 commit into from Jun 2, 2020

Conversation

davidcheung
Copy link
Contributor

@davidcheung davidcheung commented Jun 1, 2020

#134

  • Should the created projects be checked into github automatically? (Y/n): y
  • What’s the root of the github org to create repositories in? : github.com/my-org/
  • Github Personal Access Token with access to the above organization : ABCD1234

#127

  • Dedupe based on elimination(passed context and remove by key)

#135

  • creating ~/.zero/credentials.yml
  • reading ~/.zero/credentials.yml
  • writing basic project config to ~/.zero/credentials.yml

Outstanding

  • per module ask for directory name to use [backend/infrastructure/frontned]
  • tests for any the prompts

@bmonkman
Copy link
Member

bmonkman commented Jun 1, 2020

Based on @cjhawkins 's PR regarding github it seems like we may need to switch around what we ask for here since we need to know if it's a personal repo or organizational, but we can handle that in another PR.


var GetCredentialsPath = getCredentialsPath

type Projects map[string]*Project
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for these to be pointers to structs instead of just structs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can we call this something more specific? Credentials and ProjectCredentials?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I need to persist the changes I make to the Project, the map[string]Project doesn't get the updated value otherwise

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only because Save is a pointer receiver. It could also be called like config.Save(projects) instead of projects.Save() There are a few things in this PR which look like they are structured in an OOP way which is not how things are typically done in Go.

internal/context/init.go Outdated Show resolved Hide resolved
internal/context/init.go Outdated Show resolved Hide resolved
@@ -0,0 +1,103 @@
package config_test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests!

log.Fatal(err)
}
}
func TestReadOrCreateUserCredentialsFile(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should really be testing the API of the package rather than the internals. By calling a function like ReadOrCreateUserCredentialsFile it means that function now has to be exported, and I would think the only exported functions would be LoadUserCredentials and Save

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, should I create another file for tests like this under the config package? so I can keep them private and still test them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, though the general practice is try to make your tests in the _test package, then test the exported stuff and not the internals so that your test is coupled to the "API" which should be stable and not the internals which could change. And if you get to the point where the "API" is masking a massive amount of code, try to split it up into smaller packages which can be easily tested in isolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants