package variable import ( "bytes" "testing" "github.com/yuin/goldmark" ) func TestVarExtension(t *testing.T) { markdown := goldmark.New( goldmark.WithExtensions( New(), ), ) tests := []struct { name string input string expected string }{ { name: "basic variable reference", input: "{var}`pkgs.virtualbox`", expected: "
pkgs.virtualbox
\n", }, { name: "variable reference in sentence", input: "Use {var}`nixpkgs.lib.attrsets` to manipulate attribute sets.", expected: "Use nixpkgs.lib.attrsets to manipulate attribute sets.
\n", }, { name: "multiple variable references", input: "Both {var}`config.services.nginx` and {var}`config.services.postgresql` define service configurations.", expected: "Both config.services.nginx and " + "config.services.postgresql define service configurations.
\n", }, { name: "incomplete variable reference - no closing backtick", input: "{var}`MISSING_BACKTICK", expected: "{var}`MISSING_BACKTICK
\n", }, { name: "incomplete variable reference - empty variable name", input: "{var}``", expected: "{var}``
\n", }, { name: "variable reference with code block", input: "Set {var}`pkgs.hello` in your `configuration.nix` file.", expected: "Set pkgs.hello " +
"in your configuration.nix
file.