...

Source file src/github.com/go-kivik/kivik/v4/x/fsdb/common_test.go

Documentation: github.com/go-kivik/kivik/v4/x/fsdb

     1  // Licensed under the Apache License, Version 2.0 (the "License"); you may not
     2  // use this file except in compliance with the License. You may obtain a copy of
     3  // the License at
     4  //
     5  //  http://www.apache.org/licenses/LICENSE-2.0
     6  //
     7  // Unless required by applicable law or agreed to in writing, software
     8  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     9  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    10  // License for the specific language governing permissions and limitations under
    11  // the License.
    12  
    13  package fs
    14  
    15  import (
    16  	"os"
    17  	"testing"
    18  )
    19  
    20  func tempDir(t *testing.T) string {
    21  	t.Helper()
    22  	dir, err := os.MkdirTemp("", "kivik-fsdb-")
    23  	if err != nil {
    24  		t.Fatal(err)
    25  	}
    26  	return dir
    27  }
    28  
    29  func rmdir(t *testing.T, dir string) {
    30  	t.Helper()
    31  	if err := os.RemoveAll(dir); err != nil {
    32  		t.Fatal(err)
    33  	}
    34  }
    35  
    36  func cleanTmpdir(path string) func() error {
    37  	return func() error {
    38  		return os.RemoveAll(path)
    39  	}
    40  }
    41  

View as plain text