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

adds support for multiple mocks and service prefix #1570

Merged
merged 7 commits into from
May 3, 2021

Conversation

ivangsa
Copy link
Contributor

@ivangsa ivangsa commented Apr 21, 2021

Description

adds support for multiple mocks and service prefix

Ivan Garcia Sainz-Aja and others added 4 commits April 21, 2021 16:38
code blocks refactoring for better mainteinance
Copy link
Member

@ptrthomas ptrthomas left a comment

Choose a reason for hiding this comment

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

thanks for this, this is good stuff. requested minor changes

File mock;

@Option(names = {"-m", "--mocks"}, split = ",", description = "one or more mock server files")
Copy link
Member

Choose a reason for hiding this comment

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

I'd like both --mock and --mocks to have the exact same behavior. can you check if this is possible with picocli

@Option(names = {"-m", "--mocks"}, split = ",", description = "one or more mock server files")
List<File> mocks;

@Option(names = {"-P", "--prefix"}, description = "mock server prefix (contextPath)")
Copy link
Member

Choose a reason for hiding this comment

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

this is good. can you update the description to mock server path prefix (context-path)

MockServer.Builder builder = MockServer
.feature(mock)
.featureFiles(features)
.prefix(prefix)
Copy link
Member

Choose a reason for hiding this comment

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

rename builder method to pathPrefix()

@@ -263,12 +322,12 @@ public boolean methodIs(String name) { // TODO no more supporting array arg

public boolean typeContains(String text) {
String contentType = LOCAL_REQUEST.get().getContentType();
return contentType == null ? false : contentType.contains(text);
return contentType != null && contentType.contains(text);
Copy link
Member

Choose a reason for hiding this comment

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

thanks :)

@ivangsa ivangsa marked this pull request as ready for review May 3, 2021 06:46
@ptrthomas ptrthomas merged commit 178a98a into karatelabs:develop May 3, 2021
ptrthomas added a commit that referenced this pull request May 20, 2021
ptrthomas added a commit that referenced this pull request Apr 3, 2022
at a path defined by [pathPrefix] ref #1570
@ptrthomas
Copy link
Member

@ivangsa when you can review the last commit - do comment. I think being able to "mount" a mock on a URL path provides for some good flexibility

@ivangsa
Copy link
Contributor Author

ivangsa commented Apr 4, 2022

@ivangsa when you can review the last commit - do comment. I think being able to "mount" a mock on a URL path provides for some good flexibility

looks more consistent now, but introduces an unnecesary breaking change for mocks that are already setting the prefix withouth first "/"

.pathPrefix("api/v3")

leads to:

java.lang.IllegalArgumentException: prefix: api/v3 (expected: an absolute path starting with '/')
	at com.linecorp.armeria.internal.server.RouteUtil.ensureAbsolutePath(RouteUtil.java:59)

maybe it's just a matter to adding the "/" if is missing inside Builder pathPrefix

@ptrthomas
Copy link
Member

@ivangsa ok I'll take care of that

ptrthomas added a commit that referenced this pull request Apr 4, 2022
This pull request was closed.
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.

3 participants