Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Add WorkItemType Field type verification/tests #77

Closed
aslakknutsen opened this issue Aug 3, 2016 · 5 comments
Closed

Add WorkItemType Field type verification/tests #77

aslakknutsen opened this issue Aug 3, 2016 · 5 comments

Comments

@aslakknutsen
Copy link
Contributor

Verify that a WorkItem's Fields can be converted/verified to the correct Type as defined in the WorkItemType definition.

Create a set of unit tests that verify the different Field Type|Kinds can be handled. (and fix code if not working as expected ;)

Kinds: https://github.com/almighty/almighty-core/blob/master/models/field_definition.go#L11
Workitem: https://github.com/almighty/almighty-core/blob/master/models/workitem.go
WorkItemType: https://github.com/almighty/almighty-core/blob/master/models/workitemtype.go

This sounds like a good case for a Table test: https://github.com/golang/go/wiki/TableDrivenTests

Table could contain: field type, value, expected result
Then the test loop over the table;

  • Creates a WorkItemType with the FieldType
  • Creates a WorkItem with the value
  • Verify expected result when WorkItem is verified against WorkItemType

Ref: https://trello.com/c/nqXR6XHS/66-expand-hardcoded-work-item-types

@pranavgore09
Copy link
Contributor

pranavgore09 commented Aug 10, 2016

Hello @aslakknutsen @tsmaeder @kwk
I found this repo
Seems good for adding validations in Validate method. And we can have custom validations as and when needed in future.

@tsmaeder
Copy link
Contributor

I think this task is about adding tests, not a validation infrastructure.

@pranavgore09
Copy link
Contributor

@tsmaeder What I understood from this ticket and hipchat discussion is - there should be a way for checking "Kind" properly. URL pattern, User instance etc etc should be checked before/while creating WI. Currently the method "ConvertToModel" does not validate types. So added validation infra around.
@aslakknutsen can you please help. I thought the PR created yesterday[https://github.com//pull/106] was in right direction.

We can discuss on how I can extend this ticket to have validation infra, please let me know.

@aslakknutsen
Copy link
Contributor Author

@pranavgore09 @tsmaeder Sorry, this got a bit messy. The intent of this task is to verify the Convert does what it should. The Convert is basically a simple DataType conversion from Domain to Storage and back. And this is the wrong layer for the Validation that came up. The Validation of Data content etc should be in the non-existing Domain layer(ref #110). So the thoughts/work around the Validation is not lost, it's just not the correct level to have it. So drop expanding on the Validation part for this part, just verify the Conversion.

@pranavgore09
Copy link
Contributor

thanks @aslakknutsen
Got it, I will focus on testing convert logic.

@tsmaeder tsmaeder modified the milestones: Sprint #119, Sprint #118 Aug 17, 2016
pranavgore09 pushed a commit to pranavgore09/fabric8-wit that referenced this issue Aug 18, 2016
These test cases are testing ConvertToModel function of the Type. Also added fixes in existing ConvertToModel as needed.
Few validations are added in Conversion logic. govalidator lib is added for the validations like IsURL.

Fixes: fabric8-services#77
@kwk kwk closed this as completed in 72a5560 Aug 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants