File tree Expand file tree Collapse file tree
sbt-dotenv/check-load-on-demand-dot-env
sbt1only/check-load-on-demand-dot-env Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 java-version : 17
1616 - uses : sbt/setup-sbt@v1
1717 - name : Run tests
18- run : sbt clean +test +scripted
18+ run : sbt clean +test 'scripted sbt1only/*' ' +scripted sbt-dotenv/*'
Original file line number Diff line number Diff line change 1+ lazy val root = (project in file(" ." ))
2+ .settings(
3+ version := " 0.1" ,
4+ ThisBuild / envFileName := " build.env" ,
5+ Test / envFileName := " test.env" ,
6+ test / fork := true
7+ )
8+
9+ TaskKey [Unit ](" checkGlobal" ) := {
10+ val lastLog : File = BuiltinCommands .lastLogFile(state.value).get
11+ val last : String = IO .read(lastLog)
12+ val contains = last.contains(
13+ " .env file not found (fileName=build.env), no .env environment configured."
14+ )
15+ if (! contains)
16+ sys.error(" expected log message" )
17+ }
18+
19+ TaskKey [Unit ](" checkTest" ) := {
20+ val lastLog : File = BuiltinCommands .lastLogFile(state.value).get
21+ val last : String = IO .read(lastLog)
22+ val contains = last.contains(" .env detected (fileName=test.env)" )
23+ if (! contains)
24+ sys.error(" expected log message" )
25+ }
Original file line number Diff line number Diff line change 1+ sys.props.get(" plugin.version" ) match {
2+ case Some (x) => addSbtPlugin(" nl.gn0s1s" %% " sbt-dotenv" % x)
3+ case _ =>
4+ sys.error(
5+ """ |The system property 'plugin.version' is not defined.
6+ |Specify this property using the scriptedLaunchOpts -D.""" .stripMargin
7+ )
8+ }
Original file line number Diff line number Diff line change 1+ > checkGlobal
2+
3+ > set Test / envVars := (Test / envFromFile).value
4+
5+ > test
6+
7+ > checkTest
Original file line number Diff line number Diff line change 1+ LINE_ONE = abc
2+ LINE_TWO = xyz
Original file line number Diff line number Diff line change 1+ lazy val root = (project in file(" ." ))
2+ .configs(IntegrationTest )
3+ .settings(Defaults .itSettings)
4+ .settings(
5+ version := " 0.1" ,
6+ ThisBuild / envFileName := " build.env" ,
7+ Test / envFileName := " test.env" ,
8+ IntegrationTest / envFileName := " integration.env" ,
9+ test / fork := true ,
10+ IntegrationTest / fork := true
11+ )
12+
13+ TaskKey [Unit ](" checkGlobal" ) := {
14+ val lastLog : File = BuiltinCommands .lastLogFile(state.value).get
15+ val last : String = IO .read(lastLog)
16+ val contains = last.contains(
17+ " .env file not found (fileName=build.env), no .env environment configured."
18+ )
19+ if (! contains)
20+ sys.error(" expected log message" )
21+ }
22+
23+ TaskKey [Unit ](" checkTest" ) := {
24+ val lastLog : File = BuiltinCommands .lastLogFile(state.value).get
25+ val last : String = IO .read(lastLog)
26+ val contains = last.contains(" .env detected (fileName=test.env)" )
27+ if (! contains)
28+ sys.error(" expected log message" )
29+ }
30+
31+ TaskKey [Unit ](" checkIntegrationTest" ) := {
32+ val lastLog : File = BuiltinCommands .lastLogFile(state.value).get
33+ val last : String = IO .read(lastLog)
34+ val contains = last.contains(" .env detected (fileName=integration.env)" )
35+ if (! contains)
36+ sys.error(" expected log message" )
37+ }
Original file line number Diff line number Diff line change 1+ LINE_ONE = 123
2+ LINE_TWO = 456
Original file line number Diff line number Diff line change 1+ sys.props.get(" plugin.version" ) match {
2+ case Some (x) => addSbtPlugin(" nl.gn0s1s" %% " sbt-dotenv" % x)
3+ case _ =>
4+ sys.error(
5+ """ |The system property 'plugin.version' is not defined.
6+ |Specify this property using the scriptedLaunchOpts -D.""" .stripMargin
7+ )
8+ }
Original file line number Diff line number Diff line change 1+ > checkGlobal
2+
3+ > set Test / envVars := (Test / envFromFile).value
4+
5+ > set IntegrationTest / envVars := (IntegrationTest / envFromFile).value
6+
7+ > test
8+
9+ > checkTest
10+
11+ > IntegrationTest / test
12+
13+ > checkIntegrationTest
14+
Original file line number Diff line number Diff line change 1+ LINE_ONE = abc
2+ LINE_TWO = xyz
You can’t perform that action at this time.
0 commit comments