github.com/dubbogo/gost@v1.14.0/path/filepath/path_test.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package gxfilepath 19 20 import ( 21 "testing" 22 ) 23 24 import ( 25 "github.com/stretchr/testify/assert" 26 ) 27 28 func TestFileExists(t *testing.T) { 29 file := "./path_test.go" 30 ok, err := Exists(file) 31 assert.True(t, ok) 32 assert.Nil(t, err) 33 ok, err = DirExists(file) 34 assert.False(t, ok) 35 assert.NotNil(t, err) 36 ok, err = FileExists(file) 37 assert.True(t, ok) 38 assert.Nil(t, err) 39 40 file = "./path_test1.go" 41 ok, err = Exists(file) 42 assert.False(t, ok) 43 assert.Nil(t, err) 44 ok, err = DirExists(file) 45 assert.False(t, ok) 46 assert.NotNil(t, err) 47 ok, err = FileExists(file) 48 assert.False(t, ok) 49 assert.NotNil(t, err) 50 } 51 52 func TestDirExists(t *testing.T) { 53 file := "./" 54 ok, err := Exists(file) 55 assert.True(t, ok) 56 assert.Nil(t, err) 57 ok, err = DirExists(file) 58 assert.True(t, ok) 59 assert.Nil(t, err) 60 ok, err = FileExists(file) 61 assert.False(t, ok) 62 assert.NotNil(t, err) 63 64 file = "./go" 65 ok, err = Exists(file) 66 assert.False(t, ok) 67 assert.Nil(t, err) 68 ok, err = DirExists(file) 69 assert.False(t, ok) 70 assert.NotNil(t, err) 71 ok, err = FileExists(file) 72 assert.False(t, ok) 73 assert.NotNil(t, err) 74 }