<commit_before>// GCloud - Go Packages for Cloud Services.
// Copyright (c) 2013 <NAME> (https://github.com/gwoo).

package compute

import (
	p "github.com/gcloud/compute/providers"
	"testing"
)

type MockImages struct{}

// List images available on the account.
func (s *MockImages) List() ([]byte, error) {
	return []byte(`[{"Name":"My Image","Id": "616fb98f-46ca-475e-917e-2563e5a8cd19"}]`), nil
}
func (s *MockImages) Show(id string) ([]byte, error) {
	return []byte(`{"Name":"My Image","Id": "616fb98f-46ca-475e-917e-2563e5a8cd19"}`), nil
}
func (s *MockImages) Create(n *p.Image) ([]byte, error) {
	return []byte(`{"Name":"My Image","Id": "616fb98f-46ca-475e-917e-2563e5a8cd19"}`), nil
}
func (s *MockImages) Destroy(id string) (bool, error) {
	return true, nil
}

func init() {
	p.RegisterImages("mock", &MockImages{})
}

func Test_ImagesList(t *testing.T) {
	images := &Images{Provider: "mock"}
	results, err := images.List()
	if err != nil {
		t.Error("Images List failed with " + err.Error() + "(bool, error).")
	}
	if results == nil {
		t.Error("Results should not be nil.")
	}
	for _, v := range *results {
		if v.Id != "616fb98f-46ca-475e-917e-2563e5a8cd19" {
			t.Error("Wrong value for Id.")
		}
		if v.Name != "My Image" {
			t.Error("Wrong value for Name.")
		}
	}
}

func Test_ImagesShow(t *testing.T) {
	images := &Images{Provider: "mock"}
	result, err := images.Show("616fb98f-46ca-475e-917e-2563e5a8cd19")
	if err != nil {
		t.Error("Images Show failed with " + err.Error() + ".")
	}
	if result == nil {
		t.Error("Results should not be nil.")
	}
	r := *result
	if r.Id != "616fb98f-46ca-475e-917e-2563e5a8cd19" {
		t.Error("Wrong value for Id.")
	}
	if r.Name != "My Image" {
		t.Error("Wrong value for Name.")
	}
}

func Test_ImagesCreate(t *testing.T) {
	images := &Images{Provider: "mock"}
	result, err := images.Create(&p.Image{
		Name: "My Image"})
	if err != nil {
		t.Error("Images Create failed with " + err.Error() + ".")
	}
	if result == nil {
		t.Error("Results should not be nil.")
	}
	r := *result
	if r.Id != "616fb98f-46ca-475e-917e-2563e5a8cd19" {
		t.Error("Wrong value for Id.")
	}
	if r.Name != "My Image" {
		t.Error("Wrong value for Name.")
	}
}

func Test_ImagesDestroy(t *testing.T) {
	images := &Images{Provider: "mock"}
	ok, err := images.Destroy("616fb98f-46ca-475e-917e-2563e5a8cd19")
	if !ok {
		t.Error("Images Destroy failed.")
	}
	if err != nil {
		t.Error("Images Destroy failed with " + err.Error() + ".")
	}
}

func Test_ImagesDistribute(t *testing.T) {
	t.Error("ImagesDistribute failed.")
}
<commit_msg>Use i in images_test and remove distribute.<commit_after>// GCloud - Go Packages for Cloud Services.
// Copyright (c) 2013 <NAME> (https://github.com/gwoo).

package compute

import (
	p "github.com/gcloud/compute/providers"
	"testing"
)

type MockImages struct{}

// List images available on the account.
func (i *MockImages) List() ([]byte, error) {
	return []byte(`[{"Name":"My Image","Id": "616fb98f-46ca-475e-917e-2563e5a8cd19"}]`), nil
}
func (i *MockImages) Show(id string) ([]byte, error) {
	return []byte(`{"Name":"My Image","Id": "616fb98f-46ca-475e-917e-2563e5a8cd19"}`), nil
}
func (i *MockImages) Create(n *p.Image) ([]byte, error) {
	return []byte(`{"Name":"My Image","Id": "616fb98f-46ca-475e-917e-2563e5a8cd19"}`), nil
}
func (i *MockImages) Destroy(id string) (bool, error) {
	return true, nil
}

func init() {
	p.RegisterImages("mock", &MockImages{})
}

func Test_ImagesList(t *testing.T) {
	images := &Images{Provider: "mock"}
	results, err := images.List()
	if err != nil {
		t.Error("Images List failed with " + err.Error() + "(bool, error).")
	}
	if results == nil {
		t.Error("Results should not be nil.")
	}
	for _, v := range *results {
		if v.Id != "616fb98f-46ca-475e-917e-2563e5a8cd19" {
			t.Error("Wrong value for Id.")
		}
		if v.Name != "My Image" {
			t.Error("Wrong value for Name.")
		}
	}
}

func Test_ImagesShow(t *testing.T) {
	images := &Images{Provider: "mock"}
	result, err := images.Show("616fb98f-46ca-475e-917e-2563e5a8cd19")
	if err != nil {
		t.Error("Images Show failed with " + err.Error() + ".")
	}
	if result == nil {
		t.Error("Results should not be nil.")
	}
	r := *result
	if r.Id != "616fb98f-46ca-475e-917e-2563e5a8cd19" {
		t.Error("Wrong value for Id.")
	}
	if r.Name != "My Image" {
		t.Error("Wrong value for Name.")
	}
}

func Test_ImagesCreate(t *testing.T) {
	images := &Images{Provider: "mock"}
	result, err := images.Create(&p.Image{
		Name: "My Image"})
	if err != nil {
		t.Error("Images Create failed with " + err.Error() + ".")
	}
	if result == nil {
		t.Error("Results should not be nil.")
	}
	r := *result
	if r.Id != "616fb98f-46ca-475e-917e-2563e5a8cd19" {
		t.Error("Wrong value for Id.")
	}
	if r.Name != "My Image" {
		t.Error("Wrong value for Name.")
	}
}

func Test_ImagesDestroy(t *testing.T) {
	images := &Images{Provider: "mock"}
	ok, err := images.Destroy("616fb98f-46ca-475e-917e-2563e5a8cd19")
	if !ok {
		t.Error("Images Destroy failed.")
	}
	if err != nil {
		t.Error("Images Destroy failed with " + err.Error() + ".")
	}
}

{'fraction_non_alphanumeric': 0.19305856832971802, 'fraction_numerical': 0.06783671859593768, 'mean_word_length': 3.8304761904761904, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '601562', 'n_tokens_mistral': 2260, 'n_tokens_neox': 2047, 'n_words': 473}