GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — dedupe by davidcheung · Pull Request #143 · commitdev/zero Conversation
| ||||||||||||||||||||||||||||||||
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ee3049f to
fa2ad3e
Compare
|
|
||
| var GetCredentialsPath = getCredentialsPath | ||
|
|
||
| type Projects map[string]*Project |
There was a problem 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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,103 @@ | |||
| package config_test | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice tests!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| log.Fatal(err) | ||
| } | ||
| } | ||
| func TestReadOrCreateUserCredentialsFile(t *testing.T) { |
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ddc7c76 to
ee91d85
Compare
43b0bbc to
2211d53
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.