Skip to content

Commit

Permalink
Rewrote tests to eliminate boilerplate and increase readability
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlauer1 committed May 23, 2024
1 parent 234e43e commit 266b974
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions api/test/OpenTelemetry/SemConvStabilityOptInSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,17 @@ spec = do
unsetEnv envVarName
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Old
it "defaults to 'Old' when env var has incorrect value" $ do
setEnv envVarName "http/du" -- intentionally similar to "http/dup" and "http"
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Old
it "is 'Stable' when env var is 'http'" $ do
setEnv envVarName "http"
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Stable
it "is 'Both' when env var is 'http/dup'" $ do
setEnv envVarName "http/dup"
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Both
it "is 'Both' when env var is 'http/dup,http'" $ do
setEnv envVarName "http/dup,http"
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Both
it "is 'Both' when env var is 'http,http/dup'" $ do
setEnv envVarName "http,http/dup"
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Both
it "is 'Both' when env var is 'http,something-random,http/dup'" $ do
setEnv envVarName "http,http/dup"
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` Both
mapM_
( \(envVarVal, expectedVal) ->
it ("returns '" ++ show expectedVal ++ "' when env var is '" ++ show envVarVal ++ "'") $ do
setEnv envVarName envVarVal
semConvStabilityOptIn <- getSemConvStabilityOptIn
semConvStabilityOptIn `shouldBe` expectedVal
)
[ ("http", Stable)
, ("http/du", Old) -- intentionally similar to both "http/dup" and "http"
, ("http/dup", Both)
, ("http/dup,http", Both)
, ("http,http/dup", Both)
, ("http,something-random,http/dup", Both)
]

0 comments on commit 266b974

Please sign in to comment.