github.com/avfs/avfs@v0.33.1-0.20240303173310-c6ba67c33eb7/idm/memidm/memidm_test.go (about)

     1  //
     2  //  Copyright 2020 The AVFS authors
     3  //
     4  //  Licensed under the Apache License, Version 2.0 (the "License");
     5  //  you may not use this file except in compliance with the License.
     6  //  You may obtain a copy of the License at
     7  //
     8  //  	http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  //  Unless required by applicable law or agreed to in writing, software
    11  //  distributed under the License is distributed on an "AS IS" BASIS,
    12  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  //  See the License for the specific language governing permissions and
    14  //  limitations under the License.
    15  //
    16  
    17  //go:build !avfs_race
    18  
    19  package memidm_test
    20  
    21  import (
    22  	"testing"
    23  
    24  	"github.com/avfs/avfs"
    25  	"github.com/avfs/avfs/idm/memidm"
    26  	"github.com/avfs/avfs/test"
    27  )
    28  
    29  var (
    30  	// MemIdm implements avfs.IdentityMgr interface.
    31  	_ avfs.IdentityMgr = &memidm.MemIdm{}
    32  
    33  	// MemUser implements avfs.UserReader interface.
    34  	_ avfs.UserReader = &memidm.MemUser{}
    35  
    36  	// MemGroup implements avfs.GroupReader interface.
    37  	_ avfs.GroupReader = &memidm.MemGroup{}
    38  )
    39  
    40  // TestMemIdmAll run all tests.
    41  func TestMemIdmAll(t *testing.T) {
    42  	idm := memidm.New()
    43  
    44  	ts := test.NewSuiteIdm(t, idm)
    45  	ts.TestIdmAll(t)
    46  }
    47  
    48  // TestMemIdmAllOSType run all tests with the current OS.
    49  func TestMemIdmAllOSType(t *testing.T) {
    50  	idm := memidm.NewWithOptions(&memidm.Options{OSType: avfs.CurrentOSType()})
    51  
    52  	ts := test.NewSuiteIdm(t, idm)
    53  	ts.TestIdmAll(t)
    54  }
    55  
    56  func TestMemIdmFeatures(t *testing.T) {
    57  	idm := memidm.New()
    58  	if idm.Features() != avfs.FeatIdentityMgr {
    59  		t.Errorf("Features : want Features to be %d, got %d", avfs.FeatIdentityMgr, idm.Features())
    60  	}
    61  }