...

Source file src/github.com/go-kivik/kivik/v4/x/fsdb/createdb_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  	"encoding/json"
    17  	"fmt"
    18  	"testing"
    19  
    20  	"gitlab.com/flimzy/testy"
    21  
    22  	"github.com/go-kivik/kivik/v4/driver"
    23  	internal "github.com/go-kivik/kivik/v4/int/errors"
    24  	"github.com/go-kivik/kivik/v4/x/fsdb/filesystem"
    25  )
    26  
    27  func TestCreateDB(t *testing.T) {
    28  	type tt struct {
    29  		driver *fsDriver
    30  		path   string
    31  		status int
    32  		err    string
    33  		want   *client
    34  	}
    35  	tests := testy.NewTable()
    36  	tests.Add("success", tt{
    37  		driver: &fsDriver{},
    38  		path:   "testdata",
    39  		want: &client{
    40  			version: &driver.Version{
    41  				Version:     Version,
    42  				Vendor:      Vendor,
    43  				RawResponse: json.RawMessage(fmt.Sprintf(`{"version":"%s","vendor":{"name":"%s"}}`, Version, Vendor)),
    44  			},
    45  			root: "testdata",
    46  			fs:   filesystem.Default(),
    47  		},
    48  	})
    49  
    50  	tests.Run(t, func(t *testing.T, tt tt) {
    51  		client, err := tt.driver.NewClient(tt.path, nil)
    52  		if d := internal.StatusErrorDiff(tt.err, tt.status, err); d != "" {
    53  			t.Error(d)
    54  		}
    55  		if d := testy.DiffInterface(tt.want, client); d != nil {
    56  			t.Error(d)
    57  		}
    58  	})
    59  }
    60  

View as plain text