<commit_before>package main

import (
	"fmt"
	"gopkg.in/yaml.v2"
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

func TestUnmarshalStringList(t *testing.T) {
	srcYAML := `
type: PS4
target: foo
list:
- list item
debug:
- debug item
release:
- release item
develop:
- develop item
develop-release:
- develop-release item
product:
- product item
`
	Convey(`Test UnmarshalStringList`, t, func() {
		var slist StringList
		err := yaml.Unmarshal([]byte(srcYAML), &slist)
		So(err, ShouldBeNil)
		Convey(`Test slots...`, func() {
			Convey(`Test fixed slots.`, func() {
				So(slist.Type, ShouldEqual, "PS4")
				So(slist.Target, ShouldEqual, "foo")
			})
			for _, k := range KnownBuildTypes {
				Convey(fmt.Sprintf(`Test "%s" slot.`, k.String()), func() {
					Convey(`Passed as KnownBuildType`, func() {
						l := slist.Items(k)
						So(*l, ShouldNotBeEmpty)
						So((*l)[0], ShouldEqual, fmt.Sprintf("%s item", k.String()))
					})
					Convey(`Passed as string`, func() {
						key := k.String()
						l := slist.Items(key)
						So(*l, ShouldNotBeEmpty)
						So((*l)[0], ShouldEqual, fmt.Sprintf("%s item", key))
					})
				})
			}
			Convey(`Unexisted key`, func() {
				l := slist.Items("foo")
				So(l, ShouldBeNil)
			})
		})
	})
}<commit_msg>test: Follow BDD style<commit_after>package main

import (
	"fmt"
	"gopkg.in/yaml.v2"
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

func TestUnmarshalStringList(t *testing.T) {
	Convey(`GIVEN: A YAML source`, t, func() {
		srcYAML := `# YAML Source
type: PS4
target: foo
list:
- list item
- dummy
debug:
- debug item
- dummy
release:
- release item
- dummy
develop:
- develop item
- dummy
develop-release:
- develop-release item
- dummy
product:
- product item
- dummy
`
		Convey("WHEN: Unmarshal", func() {
			var slist StringList
			err := yaml.Unmarshal([]byte(srcYAML), &slist)
			Convey("THEN: Should success", func() {
				So(err, ShouldBeNil)
				Convey("AND THEN: .Type should be \"PS4\"", func() {
					So(slist.Type, ShouldEqual, "PS4")
				})
				Convey("AND THEN: .Target should be \"foo\"", func() {
					So(slist.Target, ShouldEqual, "foo")
				})
				Convey(`AND WHEN: Call Items ("foo")`, func() {
					l := slist.Items("foo")
					Convey("THEN: Should return `nil`", func() {
						So(l, ShouldBeNil)
					})
				})
				Convey("AND WHEN: Call `Item` with `KnownBuildType` key", func() {
					for _, k := range KnownBuildTypes {
						Convey(fmt.Sprintf(`AND WHEN: Call Item ("%s")`, k.String()), func() {
							l := slist.Items(k)
							Convey("AND THEN: Should not return nil", func() {
								So(l, ShouldNotBeNil)
								Convey(fmt.Sprintf("AND THEN: Should return [\"%s item\", \"dummy\"]", k.String()), func() {
									So(*l, ShouldResemble, []string{fmt.Sprintf("%s item", k.String()), "dummy"})
								})
							})
						})
					}
				})
				Convey("AND WHEN: Call `Item` with `string` key", func() {
					for _, k := range KnownBuildTypes {
						Convey(fmt.Sprintf(`AND WHEN: Call Item ("%s")`, k.String()), func() {
							key := k.String()
							l := slist.Items(key)
							Convey("AND THEN: Should not return nil", func() {
								So(l, ShouldNotBeNil)
								Convey(fmt.Sprintf("AND THEN: Should return [\"%s item\", \"dummy\"]", key), func() {
									So(*l, ShouldResemble, []string{fmt.Sprintf("%s item", key), "dummy"})
								})
							})
						})
					}
				})
			})
		})
	})
}
{'fraction_non_alphanumeric': 0.1837393601408864, 'fraction_numerical': 0.0026416201937188143, 'mean_word_length': 2.935334872979215, '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': '563728', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1207, 'n_words': 294}