From a16bdddeb203789f5c712d23974fdb94a23a4734 Mon Sep 17 00:00:00 2001 From: Daniele Rondina Date: Wed, 20 May 2020 10:26:30 +0200 Subject: [PATCH] Add spectooling test suite --- pkg/spectooling/package_test.go | 87 +++++++++++++++++++++++ pkg/spectooling/spectooling_suite_test.go | 33 +++++++++ 2 files changed, 120 insertions(+) create mode 100644 pkg/spectooling/package_test.go create mode 100644 pkg/spectooling/spectooling_suite_test.go diff --git a/pkg/spectooling/package_test.go b/pkg/spectooling/package_test.go new file mode 100644 index 00000000..47429c91 --- /dev/null +++ b/pkg/spectooling/package_test.go @@ -0,0 +1,87 @@ +// Copyright © 2019-2020 Ettore Di Giacinto , +// Daniele Rondina +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, see . + +package spectooling_test + +import ( + pkg "github.com/mudler/luet/pkg/package" + . "github.com/mudler/luet/pkg/spectooling" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Spec Tooling", func() { + Context("Conversion1", func() { + + b := pkg.NewPackage("B", "1.0", []*pkg.DefaultPackage{}, []*pkg.DefaultPackage{}) + c := pkg.NewPackage("C", "1.0", []*pkg.DefaultPackage{}, []*pkg.DefaultPackage{}) + d := pkg.NewPackage("D", "1.0", []*pkg.DefaultPackage{}, []*pkg.DefaultPackage{}) + p1 := pkg.NewPackage("A", "1.0", []*pkg.DefaultPackage{b, c}, []*pkg.DefaultPackage{d}) + virtual := pkg.NewPackage("E", "1.0", []*pkg.DefaultPackage{}, []*pkg.DefaultPackage{}) + virtual.SetCategory("virtual") + p1.Provides = []*pkg.DefaultPackage{virtual} + p1.AddLabel("label1", "value1") + p1.AddLabel("label2", "value2") + p1.SetDescription("Package1") + p1.SetCategory("cat1") + p1.SetLicense("GPL") + p1.AddURI("https://github.com/mudler/luet") + p1.AddUse("systemd") + It("Convert pkg1", func() { + res := NewDefaultPackageSanitized(p1) + expected_res := &DefaultPackageSanitized{ + Name: "A", + Version: "1.0", + Category: "cat1", + PackageRequires: []*DefaultPackageSanitized{ + &DefaultPackageSanitized{ + Name: "B", + Version: "1.0", + }, + &DefaultPackageSanitized{ + Name: "C", + Version: "1.0", + }, + }, + PackageConflicts: []*DefaultPackageSanitized{ + &DefaultPackageSanitized{ + Name: "D", + Version: "1.0", + }, + }, + Provides: []*DefaultPackageSanitized{ + &DefaultPackageSanitized{ + Name: "E", + Category: "virtual", + Version: "1.0", + }, + }, + Labels: map[string]string{ + "label1": "value1", + "label2": "value2", + }, + Description: "Package1", + License: "GPL", + Uri: []string{"https://github.com/mudler/luet"}, + UseFlags: []string{"systemd"}, + } + + Expect(res).To(Equal(expected_res)) + }) + + }) +}) diff --git a/pkg/spectooling/spectooling_suite_test.go b/pkg/spectooling/spectooling_suite_test.go new file mode 100644 index 00000000..778f3ad4 --- /dev/null +++ b/pkg/spectooling/spectooling_suite_test.go @@ -0,0 +1,33 @@ +// Copyright © 2019-2020 Ettore Di Giacinto , +// Daniele Rondina +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, see . + +package spectooling_test + +import ( + "testing" + + . "github.com/mudler/luet/cmd" + config "github.com/mudler/luet/pkg/config" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestSolver(t *testing.T) { + RegisterFailHandler(Fail) + LoadConfig(config.LuetCfg) + RunSpecs(t, "Spec Tooling Suite") +}