Skip to content

Commit

Permalink
Add unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
stolowski committed Jan 15, 2021
1 parent 8b8d548 commit eb65e11
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions asserts/snapasserts/export_test.go
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*/
package snapasserts

type ByRevision = byRevision
8 changes: 8 additions & 0 deletions asserts/snapasserts/validation_sets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package snapasserts_test

import (
"fmt"
"sort"

. "gopkg.in/check.v1"

Expand Down Expand Up @@ -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)})
}

0 comments on commit eb65e11

Please sign in to comment.