...

Source file src/github.com/go-kivik/kivik/v4/x/kivikd/conf/conf_test.go

Documentation: github.com/go-kivik/kivik/v4/x/kivikd/conf

     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  //go:build !js
    14  
    15  package conf
    16  
    17  import (
    18  	"strings"
    19  	"testing"
    20  )
    21  
    22  const testConfDir = "../test/conf"
    23  
    24  func TestLoadError(t *testing.T) {
    25  	_, err := Load(testConfDir + "/serve.invalid")
    26  	if err == nil || err.Error() != `Unsupported Config Type "invalid"` {
    27  		t.Errorf("Unexpected error: %s", err)
    28  	}
    29  }
    30  
    31  func TestLoad(t *testing.T) {
    32  	c, err := Load(testConfDir + "/serve.toml")
    33  	if err != nil {
    34  		t.Errorf("Failed to load config: %s", err)
    35  	}
    36  	if v := c.GetString("httpd.bind_address"); v != "0.0.0.0" {
    37  		t.Errorf("Unexpected value %s", v)
    38  	}
    39  }
    40  
    41  func TestLoadDefault(t *testing.T) {
    42  	_, err := Load("")
    43  	if err != nil && !strings.HasPrefix(err.Error(), `Config File "serve" Not Found in`) {
    44  		t.Errorf("Failed to load default config: %s", err)
    45  	}
    46  }
    47  

View as plain text