From eb65e1164e72d6d023e50291978aaa3a0a65e3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sto=C5=82owski?= Date: Fri, 15 Jan 2021 14:48:30 +0000 Subject: [PATCH] Add unit test. --- asserts/snapasserts/export_test.go | 21 +++++++++++++++++++++ asserts/snapasserts/validation_sets_test.go | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 asserts/snapasserts/export_test.go diff --git a/asserts/snapasserts/export_test.go b/asserts/snapasserts/export_test.go new file mode 100644 index 00000000000..d2836d894e1 --- /dev/null +++ b/asserts/snapasserts/export_test.go @@ -0,0 +1,21 @@ +// -*- Mode: Go; indent-tabs-mode: t -*- + +/* + * Copyright (C) 2021 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * 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 snapasserts + +type ByRevision = byRevision diff --git a/asserts/snapasserts/validation_sets_test.go b/asserts/snapasserts/validation_sets_test.go index ed27b4ab146..74736f594d3 100644 --- a/asserts/snapasserts/validation_sets_test.go +++ b/asserts/snapasserts/validation_sets_test.go @@ -21,6 +21,7 @@ package snapasserts_test import ( "fmt" + "sort" . "gopkg.in/check.v1" @@ -644,3 +645,10 @@ func (s *validationSetsSuite) TestCheckInstalledSnapsErrorFormat(c *C) { c.Assert(err, ErrorMatches, tc.errorMsg, Commentf("#%d: ", i)) } } + +func (s *validationSetsSuite) TestSortByRevision(c *C) { + revs := []snap.Revision{snap.R(10), snap.R(4), snap.R(5), snap.R(-1)} + + sort.Sort(snapasserts.ByRevision(revs)) + c.Assert(revs, DeepEquals, []snap.Revision{snap.R(-1), snap.R(4), snap.R(5), snap.R(10)}) +}