Skip to content

Conversation

@alexandrebouthinon
Copy link
Member

@alexandrebouthinon alexandrebouthinon commented Jul 4, 2019

What does this PR do ?

Add Index controller to the SDK C#:

  • Implementation
  • Unit tests
  • Kuzzle integration

How should this be manually tested?

Run this oneliner:

$ dotnet build Kuzzle/Kuzzle.csproj && dotnet build Kuzzle.Tests/Kuzzle.Tests.csproj && dotnet test

Other changes

Travis CI / CD improvments

  • Optimize running and deployment conditions
  • Build in release mode only when deploying.

* Implementation
* Unit tests
* Kuzzle integration
@codecov
Copy link

codecov bot commented Jul 4, 2019

Codecov Report

Merging #23 into 0-dev will increase coverage by 1.42%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##            0-dev      #23      +/-   ##
==========================================
+ Coverage   81.59%   83.01%   +1.42%     
==========================================
  Files          18       19       +1     
  Lines         880      954      +74     
  Branches      107      116       +9     
==========================================
+ Hits          718      792      +74     
  Misses        155      155              
  Partials        7        7
Impacted Files Coverage Δ
Kuzzle/API/Controllers/IndexController.cs 100% <100%> (ø)
Kuzzle/Kuzzle.cs 90.56% <100%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 105d0b9...8c01014. Read the comment docs.

@alexandrebouthinon alexandrebouthinon force-pushed the index-controller branch 2 times, most recently from 50bfef4 to 4655af0 Compare July 4, 2019 15:44
* Optimize running and deployment conditions.
* Build in release mode only when deploying.
{ "index", index },
});

return (JObject)response.Result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Your files are (very) badly indented.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot to install the VIM C# plugin 😞


[Fact]
public async void ExistsAsyncTest() {
_api.SetResult(@"{result: true}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Unit tests should test all possible outcomes (use a theory instead of a fact). This should be fixed for all comparable tests.

{ "action", "refreshInternal" },
});

return (bool)response.Result["acknowledged"];
Copy link
Contributor

Choose a reason for hiding this comment

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

API routes returning {acknowledge: true} can never return acknowledge: false. These kind of responses are just to inform that the query is well-formed and will be processed. In case of error, the result is null and the response contains an error object.

This method should thus return a Task instead of a Task<bool>

}

/// <summary>
/// Delete an index from the Kuzzle persistence engine.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Delete an index from the Kuzzle persistence engine.
/// Deletes an index from the Kuzzle persistence engine.

}

/// <summary>
/// Check if an index exists in the Kuzzle persistence engine.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Check if an index exists in the Kuzzle persistence engine.
/// Checks if an index exists in the Kuzzle persistence engine.

}

/// <summary>
/// Get the autoRefresh flag value for the given index.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Get the autoRefresh flag value for the given index.
/// Gets the autoRefresh flag value for the given index.

}

/// <summary>
/// List indexes from the Kuzzle persistence engine.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// List indexes from the Kuzzle persistence engine.
/// Lists indexes from the Kuzzle persistence engine.

@alexandrebouthinon alexandrebouthinon force-pushed the index-controller branch 2 times, most recently from 2862f33 to c1c7301 Compare July 5, 2019 14:32
{ "index", index },
});

return (JObject)response.Result;
Copy link
Contributor

Choose a reason for hiding this comment

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

The result is not important here, you could return nothing (like DeleteAsync) instead

Copy link
Member Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Then the js response should be modified in the next release.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Aschen : Fixed


Response response = await api.QueryAsync(request);

return (bool)response.Result["response"];
Copy link
Contributor

Choose a reason for hiding this comment

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

The result is not important here, you could return nothing (like DeleteAsync) instead

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The JS SDK is not an example, we cannot change the return because of the breaking change but IMHO this return is not useful

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Auth = new AuthController(this);
Collection = new CollectionController(this);
Document = new DocumentController(this);
Index = new IndexController(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can add the associated unit test

@alexandrebouthinon alexandrebouthinon requested a review from Aschen July 8, 2019 13:09
.travis.yml Outdated
- name: Unit Tests
- stage: "Tests"
name: "Unit Tests"
if: type = pull_request OR (type = push && branch =~ /^master|[0-9]+-(dev|stable)$/) OR type = cron

Choose a reason for hiding this comment

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

nitpicking: unneeded parenthesis and mix of || / && with AND / OR

Suggested change
if: type = pull_request OR (type = push && branch =~ /^master|[0-9]+-(dev|stable)$/) OR type = cron
if: type = pull_request OR type = push AND branch =~ /^master|[0-9]+-(dev|stable)$/ OR type = cron

Plus: we don't have any *-stable branch: why include this pattern?

Copy link
Member Author

Choose a reason for hiding this comment

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

I include this pattern to avoid forgetting it

{ "index", index },
});

return (JObject)response.Result;

Choose a reason for hiding this comment

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

Then the js response should be modified in the next release.

");

Assert.Equal(
new JObject {
Copy link
Contributor

Choose a reason for hiding this comment

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

(nitpicking) wrong indentation

@Aschen Aschen merged commit 9c1340a into 0-dev Jul 15, 2019
@Aschen Aschen deleted the index-controller branch July 15, 2019 16:37
@scottinet scottinet mentioned this pull request Jul 17, 2019
scottinet added a commit that referenced this pull request Jul 18, 2019
# [0.2.0](https://github.com/kuzzleio/sdk-csharp/releases/tag/0.2.0) (2019-07-17)


#### New features

- [ [#22](#22) ] Add Admin controller and unit tests   ([Shiranuit](https://github.com/Shiranuit))
- [ [#23](#23) ] Add Index Controller   ([alexandrebouthinon](https://github.com/alexandrebouthinon))

#### Enhancements

- [ [#14](#14) ] Fix optional parameters design   ([scottinet](https://github.com/scottinet))
- [ [#13](#13) ] Add unit tests for the collection controller   ([scottinet](https://github.com/scottinet))
- [ [#12](#12) ] Add unit tests for the auth controller   ([scottinet](https://github.com/scottinet))
- [ [#11](#11) ] Initialize unit tests project   ([scottinet](https://github.com/scottinet))

#### Others

- [ [#24](#24) ] Rewrite WebSocket class   ([scottinet](https://github.com/scottinet), [alexandrebouthinon](https://github.com/alexandrebouthinon))
- [ [#20](#20) ] Add documentation runner   ([Aschen](https://github.com/Aschen))
- [ [#18](#18) ] Add unit test for Realtime Controller    ([ThomasF34](https://github.com/ThomasF34))
- [ [#17](#17) ] Unit tests kuzzle class   ([Aschen](https://github.com/Aschen))
- [ [#16](#16) ] Add unit tests for the server controller   ([ThomasF34](https://github.com/ThomasF34))
- [ [#15](#15) ] Add unit tests for the document controller   ([scottinet](https://github.com/scottinet))
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants