-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Borja Lorente
committed
Jan 17, 2024
1 parent
b139378
commit 4ac71a1
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
base/tests/unittests/com/google/idea/blaze/base/run/state/EnvironmentVariablesStateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.google.idea.blaze.base.run.state; | ||
|
||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import java.util.Map; | ||
|
||
/** Unit tests for {@link EnvironmentVariablesState}. */ | ||
@RunWith(JUnit4.class) | ||
public class EnvironmentVariablesStateTest { | ||
|
||
@Test | ||
public void testSetEnvVarsReadWrite() { | ||
Map<String, String> env = ImmutableMap.of("HELLO", "world", "HI", "friends"); | ||
EnvironmentVariablesState state = new EnvironmentVariablesState(); | ||
|
||
assertThat(state.getData().getEnvs()).isEmpty(); | ||
state.setEnvVars(env); | ||
|
||
RunConfigurationStateEditor editor = state.getEditor(null); | ||
editor.resetEditorFrom(state); | ||
editor.applyEditorTo(state); | ||
|
||
assertThat(state.getData().getEnvs()).isEqualTo(env); | ||
assertThat(state.asBlazeTestEnvFlags()) | ||
.containsExactly("--test_env", "HELLO=world", "--test_env", "HI=friends") | ||
.inOrder(); | ||
} | ||
|
||
@Test | ||
public void testAsBlazeTestFlags() { | ||
EnvironmentVariablesState state = new EnvironmentVariablesState(); | ||
assertThat(state.asBlazeTestEnvFlags()).isEmpty(); | ||
state.setEnvVars(ImmutableMap.of("HELLO", "world", "HI", "friends")); | ||
assertThat(state.asBlazeTestEnvFlags()) | ||
.containsExactly("--test_env", "HELLO=world", "--test_env", "HI=friends") | ||
.inOrder(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters