<commit_before>package sous

import (
	"bytes"
	"encoding/json"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDumpDeployments(t *testing.T) {
	assert := assert.New(t)

	io := &bytes.Buffer{}
	ds := NewDeployments()
	ds.Add(&Deployment{ClusterName: "andromeda"})

	DumpDeployments(io, ds)
	assert.Regexp(`andromeda`, io.String())
}

func TestJSONDeployments(t *testing.T) {
	io := &bytes.Buffer{}
	ds := NewDeployments()
	ds.Add(&Deployment{SourceID: MustNewSourceID("andromeda", "", "1")})
	ds.Add(&Deployment{SourceID: MustNewSourceID("el_gordo", "", "1")})

	JSONDeployments(io, ds)
	var nonemptyLines = func(b []byte) [][]byte {<commit_msg>lib: failing test: DumpDeployStatuses<commit_after>package sous

import (
	"bytes"
	"encoding/json"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDumpDeployments(t *testing.T) {
	assert := assert.New(t)

	io := &bytes.Buffer{}
	ds := NewDeployments()
	ds.Add(&Deployment{ClusterName: "andromeda"})

	DumpDeployments(io, ds)
	assert.Regexp(`andromeda`, io.String())
}

func TestDumpDeployStatuses(t *testing.T) {
	assert := assert.New(t)

	io := &bytes.Buffer{}
	ds := NewDeployStates()
	status := DeployStatusPending
	ds.Add(&DeployState{
		Status:     status,
		Deployment: Deployment{ClusterName: "andromeda"},
	})

	DumpDeployStatuses(io, ds)
	assert.Regexp(`andromeda`, io.String())
	assert.Regexp(status.String(), io.String())
}

func TestJSONDeployments(t *testing.T) {
	io := &bytes.Buffer{}
	ds := NewDeployments()
	ds.Add(&Deployment{SourceID: MustNewSourceID("andromeda", "", "1")})
	ds.Add(&Deployment{SourceID: MustNewSourceID("el_gordo", "", "1")})

	JSONDeployments(io, ds)
	var nonemptyLines = func(b []byte) [][]byte {
{'fraction_non_alphanumeric': 0.17905207723815098, 'fraction_numerical': 0.0023405500292568754, 'mean_word_length': 5.867469879518072, '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': '3076504', 'n_tokens_mistral': 670, 'n_tokens_neox': 656, 'n_words': 110}