github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/apps/distgo/cmd/publish/pom_test.go (about) 1 // Copyright 2016 Palantir Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package publish 16 17 import ( 18 "testing" 19 20 "github.com/stretchr/testify/assert" 21 "github.com/stretchr/testify/require" 22 23 "github.com/palantir/godel/apps/distgo/params" 24 "github.com/palantir/godel/apps/distgo/templating" 25 ) 26 27 func TestGeneratePOM(t *testing.T) { 28 for i, currCase := range []struct { 29 name string 30 cfg templating.Config 31 distType string 32 classifier string 33 want string 34 }{ 35 { 36 "Configuration", 37 templating.Config{ 38 ProductName: "foo", 39 ProductVersion: "1.0.0", 40 Publish: params.Publish{ 41 GroupID: "com.org.group", 42 }, 43 }, 44 "tgz", 45 "", 46 `<?xml version="1.0" encoding="UTF-8"?> 47 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" 48 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 49 <modelVersion>4.0.0</modelVersion> 50 <groupId>com.org.group</groupId> 51 <artifactId>foo</artifactId> 52 <version>1.0.0</version> 53 <packaging>tgz</packaging> 54 </project> 55 `, 56 }, 57 } { 58 bytes, err := generatePOM(templating.Config{ 59 ProductName: "foo", 60 ProductVersion: "1.0.0", 61 Publish: params.Publish{ 62 GroupID: "com.org.group", 63 }, 64 }, "tgz") 65 require.NoError(t, err) 66 assert.Equal(t, currCase.want, string(bytes), "Case %d: %s", i, currCase.name) 67 } 68 }