示例#1
0
func (s *backendSuite) TestMergeSnippetMapOK(c *C) {
	snippetMap := map[string][]*systemd.Snippet{
		"security-tag": {
			{
				Services: map[string]systemd.Service{
					"foo.service": {ExecStart: "/bin/true"},
				},
			},
		},
		"another-tag": {
			{
				Services: map[string]systemd.Service{
					"bar.service": {ExecStart: "/bin/false"},
				},
			},
		},
	}
	snippet, err := systemd.MergeSnippetMap(snippetMap)
	c.Assert(err, IsNil)
	c.Assert(snippet, DeepEquals, &systemd.Snippet{
		Services: map[string]systemd.Service{
			"foo.service": {ExecStart: "/bin/true"},
			"bar.service": {ExecStart: "/bin/false"},
		},
	})
}
示例#2
0
func (s *backendSuite) TestMergeSnippetMapClashing(c *C) {
	snippetMap := map[string][]*systemd.Snippet{
		"security-tag": {
			{
				Services: map[string]systemd.Service{
					"foo.service": {ExecStart: "/bin/true"},
				},
			},
		},
		"another-tag": {
			{
				Services: map[string]systemd.Service{
					"foo.service": {ExecStart: "/bin/evil"},
				},
			},
		},
	}
	snippet, err := systemd.MergeSnippetMap(snippetMap)
	c.Assert(err, ErrorMatches, `interface require conflicting system needs`)
	c.Assert(snippet, IsNil)
}