-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated SemanticsConfig tests. NOTE: does not currently pass memoizat…
…ion tests.
- Loading branch information
1 parent
591ac8c
commit 77b4c5f
Showing
5 changed files
with
50 additions
and
35 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
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
module OpenTelemetry.SemanticsConfigSpec where | ||
|
||
import OpenTelemetry.SemanticsConfig | ||
import System.Environment | ||
import Test.Hspec | ||
|
||
|
||
envVarName :: String | ||
envVarName = "OTEL_SEMCONV_STABILITY_OPT_IN" | ||
|
||
|
||
spec :: Spec | ||
spec = do | ||
describe "SemanticsConfig" $ do | ||
describe "HttpOption" $ do | ||
it "defaults to 'Old' when env var has no value" $ do | ||
unsetEnv envVarName | ||
semanticsOptions <- getSemanticsOptions' | ||
httpOption semanticsOptions `shouldBe` Old | ||
mapM_ | ||
( \(envVarVal, expectedVal) -> | ||
it ("returns " ++ show expectedVal ++ " when env var is " ++ show envVarVal) $ do | ||
setEnv envVarName envVarVal | ||
semanticsOptions <- getSemanticsOptions' | ||
httpOption semanticsOptions `shouldBe` expectedVal | ||
) | ||
[ ("http", Stable) | ||
, ("http/du", Old) -- intentionally similar to both "http/dup" and "http" | ||
, ("http/dup", StableAndOld) | ||
, ("http/dup,http", StableAndOld) | ||
, ("http,http/dup", StableAndOld) | ||
, ("http,something-random,http/dup", StableAndOld) | ||
] | ||
context "memoization" $ do | ||
it "works" $ do | ||
setEnv envVarName "http" | ||
semanticsOptions <- getSemanticsOptions | ||
httpOption semanticsOptions `shouldBe` Stable | ||
it ("does not change when " ++ envVarName ++ " changes") $ do | ||
setEnv envVarName "http" | ||
semanticsOptions <- getSemanticsOptions | ||
setEnv envVarName "http/dup" | ||
semanticsOptions <- getSemanticsOptions | ||
httpOption semanticsOptions `shouldBe` Stable -- and not StableAndOld because of memoization |
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