mirror of https://github.com/status-im/consul.git
Tests and comments regarding the previous 2 commits
This commit is contained in:
parent
b29546e578
commit
67402b3d26
|
@ -13,7 +13,11 @@ export default Model.extend({
|
|||
[SLUG_KEY]: attr('string'),
|
||||
LockIndex: attr('number'),
|
||||
Flags: attr('number'),
|
||||
Value: attr('string'),
|
||||
// TODO: Consider defaulting all strings to '' because `typeof null !== 'string'`
|
||||
// look into what other transformers do with `null` also
|
||||
// preferably removeNull would be done in this layer also as if a property is `null`
|
||||
// default Values don't kick in, which also explains `Tags` elsewhere
|
||||
Value: attr('string'), //, {defaultValue: function() {return '';}}
|
||||
CreateIndex: attr('string'),
|
||||
ModifyIndex: attr('string'),
|
||||
Session: attr('string'),
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
@setupApplicationTest
|
||||
Feature: dc / kvs / update: KV Update
|
||||
Scenario: Update to [Name] change value to [Value]
|
||||
Background:
|
||||
Given 1 datacenter model with the value "datacenter"
|
||||
Scenario: Update to [Name] change value to [Value]
|
||||
And 1 kv model from yaml
|
||||
---
|
||||
Key: [Name]
|
||||
|
@ -25,6 +26,54 @@ Feature: dc / kvs / update: KV Update
|
|||
| key-name | a value |
|
||||
| folder/key-name | a value |
|
||||
--------------------------------------------
|
||||
Scenario: Update to a key change value to ' '
|
||||
And 1 kv model from yaml
|
||||
---
|
||||
Key: key
|
||||
---
|
||||
When I visit the kv page for yaml
|
||||
---
|
||||
dc: datacenter
|
||||
kv: key
|
||||
---
|
||||
Then the url should be /datacenter/kv/key/edit
|
||||
Then I fill in with yaml
|
||||
---
|
||||
value: ' '
|
||||
---
|
||||
And I submit
|
||||
Then a PUT request is made to "/v1/kv/key?dc=datacenter" with the body " "
|
||||
Scenario: Update to a key change value to ''
|
||||
And 1 kv model from yaml
|
||||
---
|
||||
Key: key
|
||||
---
|
||||
When I visit the kv page for yaml
|
||||
---
|
||||
dc: datacenter
|
||||
kv: key
|
||||
---
|
||||
Then the url should be /datacenter/kv/key/edit
|
||||
Then I fill in with yaml
|
||||
---
|
||||
value: ''
|
||||
---
|
||||
And I submit
|
||||
Then a PUT request is made to "/v1/kv/key?dc=datacenter" with no body
|
||||
Scenario: Update to a key when the value is empty
|
||||
And 1 kv model from yaml
|
||||
---
|
||||
Key: key
|
||||
Value: ~
|
||||
---
|
||||
When I visit the kv page for yaml
|
||||
---
|
||||
dc: datacenter
|
||||
kv: key
|
||||
---
|
||||
Then the url should be /datacenter/kv/key/edit
|
||||
And I submit
|
||||
Then a PUT request is made to "/v1/kv/key?dc=datacenter" with no body
|
||||
@ignore
|
||||
Scenario: The feedback dialog says success or failure
|
||||
Then ok
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
export default function(type) {
|
||||
let url = null;
|
||||
let requests = null;
|
||||
switch (type) {
|
||||
case 'dc':
|
||||
url = ['/v1/catalog/datacenters'];
|
||||
requests = ['/v1/catalog/datacenters'];
|
||||
break;
|
||||
case 'service':
|
||||
url = ['/v1/internal/ui/services', '/v1/health/service/'];
|
||||
requests = ['/v1/internal/ui/services', '/v1/health/service/'];
|
||||
break;
|
||||
case 'node':
|
||||
url = ['/v1/internal/ui/nodes'];
|
||||
requests = ['/v1/internal/ui/nodes'];
|
||||
break;
|
||||
case 'kv':
|
||||
url = '/v1/kv/';
|
||||
requests = ['/v1/kv/'];
|
||||
break;
|
||||
case 'acl':
|
||||
url = ['/v1/acl/list'];
|
||||
requests = ['/v1/acl/list'];
|
||||
break;
|
||||
case 'session':
|
||||
url = ['/v1/session/node/'];
|
||||
requests = ['/v1/session/node/'];
|
||||
break;
|
||||
}
|
||||
return function(actual) {
|
||||
if (url === null) {
|
||||
// TODO: An instance of URL should come in here (instead of 2 args)
|
||||
return function(url, method) {
|
||||
if (requests === null) {
|
||||
return false;
|
||||
}
|
||||
if (typeof url === 'string') {
|
||||
return url === actual;
|
||||
}
|
||||
return url.some(function(item) {
|
||||
return actual.indexOf(item) === 0;
|
||||
return requests.some(function(item) {
|
||||
return method.toUpperCase() === 'GET' && url.indexOf(item) === 0;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -207,12 +207,20 @@ export default function(assert) {
|
|||
);
|
||||
assert.equal(request.url, url, `Expected the request url to be ${url}, was ${request.url}`);
|
||||
const body = request.requestBody;
|
||||
assert.equal(
|
||||
body,
|
||||
data,
|
||||
`Expected the request body to be ${body}, was ${request.requestBody}`
|
||||
);
|
||||
assert.equal(body, data, `Expected the request body to be ${data}, was ${body}`);
|
||||
})
|
||||
.then('a $method request is made to "$url" with no body', function(method, url) {
|
||||
const request = api.server.history[api.server.history.length - 2];
|
||||
assert.equal(
|
||||
request.method,
|
||||
method,
|
||||
`Expected the request method to be ${method}, was ${request.method}`
|
||||
);
|
||||
assert.equal(request.url, url, `Expected the request url to be ${url}, was ${request.url}`);
|
||||
const body = request.requestBody;
|
||||
assert.equal(body, null, `Expected the request body to be null, was ${body}`);
|
||||
})
|
||||
|
||||
.then('a $method request is made to "$url"', function(method, url) {
|
||||
const request = api.server.history[api.server.history.length - 2];
|
||||
assert.equal(
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
"@glimmer/di" "^0.2.0"
|
||||
|
||||
"@hashicorp/api-double@^1.3.0":
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@hashicorp/api-double/-/api-double-1.3.1.tgz#fd9d706674b934857a638459c2bb52d2f2809455"
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@hashicorp/api-double/-/api-double-1.4.0.tgz#17ddad8e55370de0d24151a38c5f029bc207cafe"
|
||||
dependencies:
|
||||
"@gardenhq/o" "^8.0.1"
|
||||
"@gardenhq/tick-control" "^2.0.0"
|
||||
|
|
Loading…
Reference in New Issue