Giter Club home page Giter Club logo

consul-mock-api's People

Contributors

findkim avatar gbolo avatar mkeeler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

consul-mock-api's Issues

Ability to set response headers

It could be nice, if we have the ability to set response headers, it could be awesome especially to handle the query meta returned on consul catalog response that takes into consideration headers such as. X-Consul-Index and also X-Consul-ContentHash

The mock api attempts to compare bytes to a pointer if a body is set

Mocking a consul API call that requires a body seems to fail.

If I attempt to mock the API call to /v1/acl/token using ACLTokenCreate

token := &api.ACLToken{
  AccessorID:  "cd45b25a-07cf-4a60-ae71-2a227eaace8e",
  SecretID:    "cd45b25a-07cf-4a60-ae71-2a227eaace8e",
  Description: "test token",
}

m.ACLTokenCreate(&token, 200, []*api.ACLToken{&token}).Once()

A call like below will always fail.

client.ACL().TokenCreate(token, nil)

It looks like there is an internal check that compares the body of the request vs what is supposed to be mocked, but it's comparing a slice of bytes to a pointer?

Diff: 0: PASS:  (string=PUT) == (string=PUT)
        	1: PASS:  (string=/v1/acl/token) == (string=/v1/acl/token)
        	2: PASS:  (map[string]string=map[]) == (map[string]string=map[])
        	3: PASS:  (map[string]string=map[]) == (map[string]string=map[])
        	4: FAIL:  ([]uint8=[123 34 67 114 101 97 116 101 73 110 100 101 120 34 58 48 44 34 77 111 100 105 102 121 73 110 100 101 120 34 58 48 44 34 65 99 99 101 115 115 111 114 73 68 34 58 34 99 100 52 53 98 50 53 97 45 48 55 99 102 45 52 97 54 48 45 97 101 55 49 45 50 97 50 50 55 101 97 97 99 101 56 101 34 44 34 83 101 99 114 101 116 73 68 34 58 34 99 100 52 53 98 50 53 97 45 48 55 99 102 45 52 97 54 48 45 97 101 55 49 45 50 97 50 50 55 101 97 97 99 101 56 101 34 44 34 68 101 115 99 114 105 112 116 105 111 110 34 58 34 116 101 115 116 32 116 111 107 101 110 34 44 34 76 111 99 97 108 34 58 102 97 108 115 101 44 34 67 114 101 97 116 101 84 105 109 101 34 58 34 48 48 48 49 45 48 49 45 48 49 84 48 48 58 48 48 58 48 48 90 34 125 10]) != (*api.ACLToken=&{0 0 cd45b25a-07cf-4a60-ae71-2a227eaace8e cd45b25a-07cf-4a60-ae71-2a227eaace8e test token [] [] [] [] false  0s <nil> 0001-01-01 00:00:00 +0000 UTC []    })

If you look near the end of the error message it shows that the slice of bytes is not equal to the pointer of *api.ACLToken.

Is this intentional, and if so, can we please get an example on the proper usage?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.