github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow@v0.28.1-0.20240311201729-34c6856b157f/pkg/command/quarkus/quarkus_project_test.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 package quarkus 21 22 import ( 23 "os" 24 "testing" 25 26 "github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/metadata" 27 ) 28 29 func TestManipulatePom(t *testing.T) { 30 31 //setup 32 metadata.KogitoVersion = "1.0.0.Final" 33 34 inputPath := "testdata/pom1-input.xml_no_auto_formatting" 35 expectedPath := "testdata/pom1-expected.xml_no_auto_formatting" 36 37 var deps = metadata.DependenciesVersion{ 38 QuarkusPlatformGroupId: "org.quarkus.fake", 39 QuarkusVersion: "0.0.1", 40 } 41 42 var cfg = CreateQuarkusProjectConfig{ 43 DependenciesVersion: deps, 44 } 45 46 tempFile := "testdata/temp.xml" 47 err := copyFile(inputPath, tempFile) 48 if err != nil { 49 t.Fatalf("Error copying test XML: %v", err) 50 } 51 defer os.Remove(tempFile) 52 53 err = manipulatePomToKogito(tempFile, cfg) 54 if err != nil { 55 t.Fatalf("Error manipulating XML: %v", err) 56 } 57 58 modifiedData, err := os.ReadFile(tempFile) 59 if err != nil { 60 t.Fatalf("Error reading modified XML: %v", err) 61 } 62 63 expectedData, err := os.ReadFile(expectedPath) 64 65 if err != nil { 66 t.Fatalf("Error reading expected XML: %v", err) 67 } 68 if string(modifiedData) != string(expectedData) { 69 t.Errorf("Manipulated XML does not match expected XML") 70 } 71 }