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

Fix potential bug in Env default value provider #644

Merged
merged 9 commits into from
Apr 7, 2020
Prev Previous commit
Next Next commit
Adding unit test case
Signed-off-by: Usman Saleem <usman@usmans.info>
  • Loading branch information
usmansaleem committed Apr 3, 2020
commit 4285157f30eadfc565becc01dc095585afc94d41
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import org.junit.Test;
import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.Model.PositionalParamSpec;
import picocli.CommandLine.Model.PositionalParamSpec.Builder;

public class EnvironmentVariableDefaultProviderTest {

Expand Down Expand Up @@ -76,4 +78,11 @@ public void shouldPreferBesuPrefixOverLegacyPrefix() {
assertThat(provider.defaultValue(OptionSpec.builder("--env-var", "--env-var-set").build()))
.isEqualTo("abc");
}

@Test
public void shouldReturnNullForPositionalParameter() {
environment.put("BESU_KEY", "abc");
final Builder positional = PositionalParamSpec.builder().descriptionKey("key");
assertThat(provider.defaultValue(positional.build())).isNull();
}
}