github.com/go-chef/chef@v0.30.1/config_rb_reader_test.go (about)

     1  package chef
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestNewClientRb(t *testing.T) {
    11  	clientRegistry["client_key"] = func(s []string, path string, m *ConfigRb) error {
    12  		str := StringParserForMeta(s)
    13  		data := strings.Split(str, "/")
    14  		m.ClientKey = data[len(data)-1]
    15  		return nil
    16  	}
    17  	data := `current_dir = File.dirname(__FILE__)
    18  		log_level                :info
    19  		log_location             STDOUT
    20  		node_name                "test"
    21  		client_key               "#{current_dir}/test.pem"
    22  		chef_server_url          "https://server/organizations/test"
    23  		cookbook_path            ["#{current_dir}/../cookbooks"]`
    24  	cb, err := NewClientRb(data, "")
    25  	if err != nil {
    26  		t.Error("unable to read config.rb file")
    27  	}
    28  	assert.Equal(t, "test.pem", cb.ClientKey)
    29  	assert.Equal(t, "https://server/organizations/test", cb.ChefServerUrl)
    30  	assert.Equal(t, "test", cb.NodeName)
    31  }