(c *C)
| 120 | } |
| 121 | |
| 122 | func (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 | |
| 155 | func (s *ModulesSuite) TestUnmarshalMarshal(c *C) { |
| 156 | input := []byte(`[submodule "foo/bar"] |
nothing calls this directly
no test coverage detected