MCPcopy Create free account
hub / github.com/go-git/go-git / TestUnmarshal

Method TestUnmarshal

config/modules_test.go:122–153  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

120}
121
122func (s *ModulesSuite) TestUnmarshal(c *C) {
123 input := []byte(`[submodule "qux"]
124 path = qux
125 url = https://github.com/foo/qux.git
126[submodule "foo/bar"]
127 path = foo/bar
128 url = https://github.com/foo/bar.git
129 branch = dev
130[submodule "suspicious"]
131 path = ../../foo/bar
132 url = https://github.com/foo/bar.git
133[submodule ".."]
134 path = deps/x
135 url = https://github.com/foo/bar.git
136`)
137
138 cfg := NewModules()
139 err := cfg.Unmarshal(input)
140 c.Assert(err, IsNil)
141
142 // The "suspicious" entry is dropped because of its `..` path,
143 // and the `..` entry is dropped because of its suspicious name
144 // (canonical Git's "ignoring suspicious submodule name" rule).
145 c.Assert(cfg.Submodules, HasLen, 2)
146 c.Assert(cfg.Submodules["qux"].Name, Equals, "qux")
147 c.Assert(cfg.Submodules["qux"].URL, Equals, "https://github.com/foo/qux.git")
148 c.Assert(cfg.Submodules["foo/bar"].Name, Equals, "foo/bar")
149 c.Assert(cfg.Submodules["foo/bar"].URL, Equals, "https://github.com/foo/bar.git")
150 c.Assert(cfg.Submodules["foo/bar"].Branch, Equals, "dev")
151 _, hasDotDot := cfg.Submodules[".."]
152 c.Assert(hasDotDot, Equals, false)
153}
154
155func (s *ModulesSuite) TestUnmarshalMarshal(c *C) {
156 input := []byte(`[submodule "foo/bar"]

Callers

nothing calls this directly

Calls 2

UnmarshalMethod · 0.95
NewModulesFunction · 0.85

Tested by

no test coverage detected