From 33c6341ccd765fa631d6863aeeca12a6a5e04658 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Wed, 19 Feb 2020 23:15:57 +0800 Subject: osutil: add unit tests --- internal/osutil/osutil_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/osutil/osutil_test.go (limited to 'internal') diff --git a/internal/osutil/osutil_test.go b/internal/osutil/osutil_test.go new file mode 100644 index 00000000..adaebebf --- /dev/null +++ b/internal/osutil/osutil_test.go @@ -0,0 +1,34 @@ +// Copyright 2020 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package osutil + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestIsFile(t *testing.T) { + tests := []struct { + path string + expVal bool + }{ + { + path: "osutil.go", + expVal: true, + }, { + path: "../osutil", + expVal: false, + }, { + path: "not_found", + expVal: false, + }, + } + for _, test := range tests { + t.Run("", func(t *testing.T) { + assert.Equal(t, test.expVal, IsFile(test.path)) + }) + } +} -- cgit v1.2.3