github.com/schumacherfm/hugo@v0.47.1/hugofs/fs_test.go (about)

     1  // Copyright 2016 The Hugo Authors. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package hugofs
    15  
    16  import (
    17  	"testing"
    18  
    19  	"github.com/spf13/afero"
    20  	"github.com/spf13/viper"
    21  	"github.com/stretchr/testify/assert"
    22  )
    23  
    24  func TestNewDefault(t *testing.T) {
    25  	v := viper.New()
    26  	f := NewDefault(v)
    27  
    28  	assert.NotNil(t, f.Source)
    29  	assert.IsType(t, new(afero.OsFs), f.Source)
    30  	assert.NotNil(t, f.Destination)
    31  	assert.IsType(t, new(afero.OsFs), f.Destination)
    32  	assert.NotNil(t, f.Os)
    33  	assert.IsType(t, new(afero.OsFs), f.Os)
    34  	assert.Nil(t, f.WorkingDir)
    35  
    36  	assert.IsType(t, new(afero.OsFs), Os)
    37  }
    38  
    39  func TestNewMem(t *testing.T) {
    40  	v := viper.New()
    41  	f := NewMem(v)
    42  
    43  	assert.NotNil(t, f.Source)
    44  	assert.IsType(t, new(afero.MemMapFs), f.Source)
    45  	assert.NotNil(t, f.Destination)
    46  	assert.IsType(t, new(afero.MemMapFs), f.Destination)
    47  	assert.IsType(t, new(afero.OsFs), f.Os)
    48  	assert.Nil(t, f.WorkingDir)
    49  }
    50  
    51  func TestWorkingDir(t *testing.T) {
    52  	v := viper.New()
    53  
    54  	v.Set("workingDir", "/a/b/")
    55  
    56  	f := NewMem(v)
    57  
    58  	assert.NotNil(t, f.WorkingDir)
    59  	assert.IsType(t, new(afero.BasePathFs), f.WorkingDir)
    60  }