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

updated implementation to comply with S3 Read/Write API endpoint spec. #14

Merged
merged 11 commits into from
Apr 3, 2017

Conversation

JuliaFernee
Copy link
Contributor

No description provided.

@nwrigh
Copy link
Contributor

nwrigh commented Mar 23, 2017

Ignore the semaphoreci thing, it was a 10% day thing that I didn't realise hooked in

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.2%) to 95.946% when pulling e2ab606 on concept_store_support into f1bf348 on master.

@@ -86,11 +88,47 @@ func TestAddAdminHandlers(t *testing.T) {
})
}

func TestMethodHandlerAcceptsNonEmptyResourcePath(t *testing.T) {
r := mux.NewRouter()
Copy link

Choose a reason for hiding this comment

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

Having re-read these tests, I think that they're testing the same as the other tests unnecessarily. I think going down the named routes route would actually be better to test the setting of the resource path.
r.Get("mh").URL("uuid", <uuid>) == /notempty/<uuid>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind changing but I am worried whether there will be a quorum? Other reviewers may think otherwise...

Copy link
Contributor

Choose a reason for hiding this comment

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

You could take out the additional tests and see if coverage goes down if you aren't convinced. Also Pete just told me that you can see inline the coverage if you use Atom as an editor - I am going to check it out now :)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 97.26% when pulling 96515fe on concept_store_support into f1bf348 on master.

Copy link
Contributor

@carlosroman carlosroman left a comment

Choose a reason for hiding this comment

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

Also, need to run go fmt ./.. on the project.

servicesRouter.Handle(fmt.Sprintf("%s%s", resourcePath, "/{uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}"), mh)
servicesRouter.Handle(fmt.Sprintf("%s%s", resourcePath, "/__count"), ch)
servicesRouter.Handle(fmt.Sprintf("%s%s", resourcePath, "/__ids"), ih)
servicesRouter.Handle(fmt.Sprintf("%s%s", resourcePath, "/"), ah)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test for /__count, /__ids and /.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 97.279% when pulling 6929ab2 on concept_store_support into f1bf348 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 96.903% when pulling c38916c on concept_store_support into f1bf348 on master.

return nil
}
func addTransactionID(params *s3.PutObjectInput, tid string) {
Copy link

Choose a reason for hiding this comment

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

I think having this as a separate function is unnecessary, it just seems to be affecting readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change it but your suggestion incourages bad coding practices as a lot of our go code does.
This has to do with excessive in-lining and dealing with more than one responsibility in a function/method, all of which increases its cyclomatic complexity. Some say the function should fit in your palm, others - it should be no more that the screen length. There is a lot of literature about it - "Code Complete", Object Calystenics, articles on refactoring by ThoughtWorks etc


func readerServiceUnavailable(uuid string, err error, rw http.ResponseWriter) {
if uuid != "" {
log.Errorf("Error from reader: '%v': %v", uuid, err.Error())
Copy link

Choose a reason for hiding this comment

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

It'd be nice if this indicated that it was the UUID being displayed, rather than just listing the values. It also doesn't need to be a %v, it should be %s as UUID is only a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

if uuid != "" {
log.Errorf("Error from reader: '%v': %v", uuid, err.Error())
} else {
log.Errorf("Error from reader: %v", err.Error())
Copy link

Choose a reason for hiding this comment

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

I disagree with splitting the errors, it's useful to know about the absence of the UUID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed to change uuid to Request URI when logging errors

err = w.Write(expectedUUID, &p, ct, expectedTransactionId)
assert.NoError(t, err)
assert.NotEmpty(t, s.putObjectInput)
assert.Equal(t, expectedTransactionId, *s.putObjectInput.Metadata[transactionid.TransactionIDKey])
Copy link

Choose a reason for hiding this comment

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

Why can't this assert just be added into TestWritingToS3? This is just duplicating that test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They shouldn't be the same. These tests test specifically that that transaction ID is passed to S3. I have re-written them in a better way. TestWritingToS3 is already testing more than it should. There used to be a rule that you have one assertion per unit test, but again with our "new Go coding standards" this is no longer the case.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 96.903% when pulling 425da23 on concept_store_support into fc4de10 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 96.882% when pulling db37964 on concept_store_support into fc4de10 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 96.882% when pulling a1058f2 on concept_store_support into fc4de10 on master.

@JuliaFernee JuliaFernee merged commit d425bb0 into master Apr 3, 2017
@scott-ace-newton scott-ace-newton deleted the concept_store_support branch April 24, 2018 10:35
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

4 participants