Uh oh!
There was an error while loading. Please reload this page.
add validate_test.go to do unit test - #188
Conversation
wking
commented
Aug 9, 2016
On Tue, Aug 09, 2016 at 04:17:40AM -0700, 梁辰晔 (Liang Chenye) wrote:
You probably want to add a Makefile and/or .travis.yml entry to run |
| for _, c := range cases { | ||
| spec.Version = c.v | ||
| msg := checkSemVer(spec, "", false) | ||
| if len(msg) != c.expected { |
There was a problem hiding this comment.
Is “number of error messages” really what we want to be checking here? I'd rather have a bunch of potential version strings with true/false for whether we thought they were valid, and error if we thought a version was valid and checkSemVer gave us error messages at all (logging the error messages with t.Fatalf) or if we thought a version was invalid and checkSemVer did not give us error messages.
There was a problem hiding this comment.
You are right, it is not necessary to check the number of error messages.
wking
commented
Aug 9, 2016
On Tue, Aug 09, 2016 at 04:17:40AM -0700, 梁辰晔 (Liang Chenye) wrote:
While I'm in favor of Go tests for our implementation, I'm not sure We'll also want a way to distinguish between “that's not valid” errors |
liangchenye
commented
Sep 1, 2016
I think it is a good idea to move 'validate' to a new directory like 'generate', I'll make a patch to move that. (just back from a long time leaving) |
liangchenye
commented
Sep 1, 2016
| expected bool | ||
| }{ | ||
| {rspec.Version, true}, | ||
| {"0.0.1", false}, |
There was a problem hiding this comment.
0.0.1 looks like valid SemVer to me. What's the error message?
There was a problem hiding this comment.
Currently only support rspec.Version.
if version != rspec.Version {
msgs = append(msgs, fmt.Sprintf("internal error: validate currently only handles version %s, but the supplied configuration targets %s", rspec.Version, version))
}
There was a problem hiding this comment.
On Mon, Sep 05, 2016 at 03:38:57AM -0700, David Liang wrote:
{"0.0.1", false},Currently only support rspec.Version.
So maybe leave a comment on this line that we're confirming a
shortcoming of the current test suite with this entry.
There was a problem hiding this comment.
Thanks, I added a 'FIXME' to mention this.
| type Validator struct { | ||
| spec rspec.Spec | ||
| rootfs string | ||
| hostSpecific bool |
There was a problem hiding this comment.
I'd rather makethesepropertiespublic, and Generator.HostSpecificis public. Do you have any reason to keep any of them private?
There was a problem hiding this comment.
Do we need to see and modify these? I think the 'Check*' functions are enough.
There was a problem hiding this comment.
On Wed, Sep 07, 2016 at 09:04:44PM -0700, 梁辰晔 (Liang Chenye) wrote:
+type Validator struct {
- spec rspec.Spec
- rootfs string
- hostSpecific bool
Do we need to see and modify these? I think the 'Check*' functions
are enough.
Making them public means you don't need getters/setters and you can
still support users who want to partially setup the instance when they
call NewValidator (or whatever 1) and finish the setup later. Or if
they want to peer inside to get more details on why their validation
is failing. Or who knows? I'd rather err on the side of “we're all
consenting adults” 2, because I don't see a way to make validation
go terribly wrong if a user gets or sets one of these values whenever
they like.
There was a problem hiding this comment.
liangchenye
commented
Sep 8, 2016
Hi @wking , I modified codes according to your suggestion. |
| return Validator{}, fmt.Errorf("Cannot find the root path %q", rootfsPath) | ||
| } else if !fi.IsDir() { | ||
| return Validator{}, fmt.Errorf("The root path %q is not a directory.", rootfsPath) | ||
| } |
There was a problem hiding this comment.
This “does the rootfs exist” check should be a separate check in Validator.CheckAll()
8d5cb3a to
a8c02cfCompareliangchenye
commented
Sep 18, 2016
| return Validator{spec: spec, bundlePath: bundlePath, HostSpecific: hostSpecific} | ||
| } | ||
| func NewValidatorFromPath(bundlePath string, hostSpecific bool) (Validator, error) { |
There was a problem hiding this comment.
I think these NewValidator* functions should return (*Validator, error).
wking
commented
Sep 19, 2016
via email
a8c02cf looks good enough to me (I think we've agreed to punt on
everything I'd still like to change). |
liangchenye
commented
Oct 6, 2016
Travis fails because of: |
liangchenye
commented
Oct 6, 2016
#7cd3aa1 rebased on top of current 'master'. @Mashimiao@mrunalp PTAL |
Only add a test case on checkSemVer in this PR.
Signed-off-by: liang chenye liangchenye@huawei.com