package envvar import ( "bytes" "testing" "github.com/yuin/goldmark" ) func TestEnvExtension(t *testing.T) { markdown := goldmark.New( goldmark.WithExtensions( New(), ), ) tests := []struct { name string input string expected string }{ { name: "basic env variable reference", input: "{env}`XDG_DATA_DIRS`", expected: "
XDG_DATA_DIRS
\n", }, { name: "env variable reference in sentence", input: "The environment variable {env}`PATH` contains a list of directories.", expected: "The environment variable PATH contains a list of directories.
\n", }, { name: "multiple env variable references", input: "Both {env}`HOME` and {env}`XDG_CONFIG_HOME` define user directories.", expected: "Both HOME and " + "XDG_CONFIG_HOME define user directories.
\n", }, { name: "incomplete env variable reference - no closing backtick", input: "{env}`MISSING_BACKTICK", expected: "{env}`MISSING_BACKTICK
\n", }, { name: "incomplete env variable reference - empty variable name", input: "{env}``", expected: "{env}``
\n", }, { name: "env variable reference with code block", input: "Set {env}`GOPATH` in your `~/.bashrc` file.", expected: "Set GOPATH " +
"in your ~/.bashrc
file.