<commit_before>package main

import (
	"encoding/json"
	"io/ioutil"
	"testing"
)

func TestDeckboxAdd(t *testing.T) {
	oldCard := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 1}}}
	sameCard := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 1}}}
	updatedEdition := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 1, Set: "Foo"}}}
	newEdition := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 2, Set: "Bar"}}}
	newCard := Card{Id: "g", Editions: []Edition{Edition{MultiverseId: 1, Set: "Foo"}}}

	box := Deckbox{Cards: []Card{oldCard}}

	box.Add(sameCard)

	card := box.Cards[0]

	if len(card.Editions) != 1 {
		t.Fatalf("Card should only have one edition, not %d", len(card.Editions))
	}

	box.Add(updatedEdition)

	card = box.Cards[0]
	set := card.Editions[0].Set

	if len(card.Editions) != 1 {
		t.Fatalf("Card should only have one edition, not %d", len(card.Editions))
	}

	if set != "Foo" {
		t.Fatalf("Card edition should be 'Foo', not '%s'", set)
	}

	box.Add(newEdition)

	card = box.Cards[0]

	if len(card.Editions) != 2 {
		t.Fatalf("Card should have two editions, not %d", len(card.Editions))
	}

	box.Add(newCard)

	if len(box.Cards) != 2 {
		t.Fatalf("Box should have two cards, not %d", len(box.Cards))
	}

}

func TestDeckboxJSON(t *testing.T) {
	path := "fixtures/testbox.json"
	box := Deckbox{Cards: []Card{Card{Id: "FOO"}}}
	err := box.Flush(path)

	if err != nil {
		t.Fatal(err)
	}

	blob, err := ioutil.ReadFile(path)

	if err != nil {<commit_msg>We now have all the editions as well<commit_after>package main

import (
	"encoding/json"
    "os"
	"io/ioutil"
	"testing"
)

func TestDeckboxAdd(t *testing.T) {
	oldCard := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 1}}}
	sameCard := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 1}}}
	updatedEdition := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 1, Set: "Foo"}}}
	newEdition := Card{Id: "f", Editions: []Edition{Edition{MultiverseId: 2, Set: "Bar"}}}
	newCard := Card{Id: "g", Editions: []Edition{Edition{MultiverseId: 1, Set: "Foo"}}}

	box := Deckbox{Cards: []Card{oldCard}}

	box.Add(sameCard)

	card := box.Cards[0]

	if len(card.Editions) != 1 {
		t.Fatalf("Card should only have one edition, not %d", len(card.Editions))
	}

	box.Add(updatedEdition)

	card = box.Cards[0]
	set := card.Editions[0].Set

	if len(card.Editions) != 1 {
		t.Fatalf("Card should only have one edition, not %d", len(card.Editions))
	}

	if set != "Foo" {
		t.Fatalf("Card edition should be 'Foo', not '%s'", set)
	}

	box.Add(newEdition)

	card = box.Cards[0]

	if len(card.Editions) != 2 {
		t.Fatalf("Card should have two editions, not %d", len(card.Editions))
	}

	box.Add(newCard)

	if len(box.Cards) != 2 {
		t.Fatalf("Box should have two cards, not %d", len(box.Cards))
	}

}

func TestDeckboxJSON(t *testing.T) {
	path := "fixtures/testbox.json"
        defer os.Remove(path)
	box := Deckbox{Cards: []Card{Card{Id: "FOO"}}}
	err := box.Flush(path)

	if err != nil {
		t.Fatal(err)
	}

	blob, err := ioutil.ReadFile(path)

	if err != nil {
{'fraction_non_alphanumeric': 0.18872229465449805, 'fraction_numerical': 0.00847457627118644, 'mean_word_length': 4.38421052631579, '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': '6092164', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1263, 'n_words': 286}