<commit_before>package chef

import (
	"fmt"
	"io/ioutil"
	"net/http"
	//"os"
	"testing"
)

const cookbookListResponseFile = "test/cookbooks_response.json"
const cookbookTestFile = "test/cookbook.json"

func TestCookbookList(t *testing.T) {
	setup()
	defer teardown()

	file, err := ioutil.ReadFile(cookbookListResponseFile)
	if err != nil {
		t.Error(err)
	}

	mux.HandleFunc("/cookbooks", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, string(file))
	})

	data, err := client.Cookbooks.List()
	if err != nil {
		t.Error(err)
	}

	if data == nil {
		t.Fatal("WTF we should have some data")
	}
	fmt.Println(data)

	_, err = client.Cookbooks.ListAvailableVersions("3")
	if err != nil {
		t.Error(err)
	}

	_, err = client.Cookbooks.ListAvailableVersions("0")
	if err != nil {
		t.Error(err)
	}
}

func TestCookbookListAvailableVersions_0(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/cookbooks", func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, "BAD FUCKING REQUEST", 503)
	})

	_, err := client.Cookbooks.ListAvailableVersions("2")
	if err == nil {
		t.Error("We expected this bad request to error", err)
	}
}

func TestCookBookDelete(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/cookbooks/good", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "")
	})
	mux.HandleFunc("/cookbooks/bad", func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, "Not Found", 404)
	})

	err := client.Cookbooks.Delete("bad", "1.1.1")
	if err == nil {
		t.Error("We expected this bad request to error", err)
	}

	err = client.Cookbooks.Delete("good", "1.1.1")
	if err != nil {
		t.Error(err)<commit_msg>fix the cookbook test cases also.<commit_after>package chef

import (
	"fmt"
	"io/ioutil"
	"net/http"
	//"os"
	"testing"
)

const cookbookListResponseFile = "test/cookbooks_response.json"
const cookbookTestFile = "test/cookbook.json"

func TestCookbookList(t *testing.T) {
	setup()
	defer teardown()

	file, err := ioutil.ReadFile(cookbookListResponseFile)
	if err != nil {
		t.Error(err)
	}

	mux.HandleFunc("/cookbooks", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, string(file))
	})

	data, err := client.Cookbooks.List()
	if err != nil {
		t.Error(err)
	}

	if data == nil {
		t.Fatal("WTF we should have some data")
	}
	fmt.Println(data)

	_, err = client.Cookbooks.ListAvailableVersions("3")
	if err != nil {
		t.Error(err)
	}

	_, err = client.Cookbooks.ListAvailableVersions("0")
	if err != nil {
		t.Error(err)
	}
}

func TestCookbookListAvailableVersions_0(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/cookbooks", func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, "BAD FUCKING REQUEST", 503)
	})

	_, err := client.Cookbooks.ListAvailableVersions("2")
	if err == nil {
		t.Error("We expected this bad request to error", err)
	}
}

func TestCookBookDelete(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/cookbooks/good/1.1.1", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "")
	})
	mux.HandleFunc("/cookbooks/bad/1.1.1", func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, "Not Found", 404)
	})

	err := client.Cookbooks.Delete("bad", "1.1.1")
	if err == nil {
		t.Error("We expected this bad request to error", err)
	}

	err = client.Cookbooks.Delete("good", "1.1.1")
	if err != nil {
		t.Error(err)
{'fraction_non_alphanumeric': 0.1652818991097923, 'fraction_numerical': 0.011275964391691394, 'mean_word_length': 4.08446455505279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2527205', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1287, 'n_words': 272}