<commit_before>package wundergo_test

import (
	"log"
	"os"

	"github.com/nu7hatch/gouuid"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/robdimsdale/wundergo"
)

var (
	client wundergo.Client
)

func contains(lists *[]wundergo.List, list *wundergo.List) bool {
	for _, l := range *lists {
		if l == *list {
			return true
		}
	}
	return false
}

var _ = Describe("Wundergo library", func() {
	BeforeEach(func() {
		accessToken := os.Getenv("WL_ACCESS_TOKEN")
		clientID := os.Getenv("WL_CLIENT_ID")

		if accessToken == "" {
			log.Fatal("Error - WL_ACCESS_TOKEN must be provided")
		}

		if clientID == "" {
			log.Fatal("Error - WL_CLIENT_ID must be provided")
		}

		client = wundergo.NewOauthClient(accessToken, clientID)
	})

	Describe("Basic list functionality", func() {
		It("creates, updates and deletes new list", func() {
			uuid1, err := uuid.NewV4()
			Expect(err).NotTo(HaveOccurred())
			newListTitle1 := uuid1.String()

			uuid2, err := uuid.NewV4()
			Expect(err).NotTo(HaveOccurred())
			newListTitle2 := uuid2.String()

			var originalLists *[]wundergo.List
			Eventually(func() error {
				originalLists, err = client.Lists()
				return err
			}).ShouldNot(HaveOccurred())

			var newList *wundergo.List
			Eventually(func() error {
				newList, err = client.CreateList(newListTitle1)
				return err
			}).ShouldNot(HaveOccurred())

			var newLists *[]wundergo.List
			Eventually(func() error {
				newLists, err = client.Lists()
				return err
			}).ShouldNot(HaveOccurred())
			Expect(contains(newLists, newList)).To(BeTrue())

			newList.Title = newListTitle2
			var updatedList *wundergo.List
			Eventually(func() error {
				updatedList, err = client.UpdateList(*newList)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1
			Expect(updatedList).To(Equal(newList))

			Eventually(func() error {
				_, err = client.TasksForListID(newList.ID)
				return err
			}).ShouldNot(HaveOccurred())

			var task *wundergo.Task
			Eventually(func() error {
				task, err = client.CreateTask(
					"myTask",
					newList.ID,
					0,
					false,
					"",
					0,
					"1970-01-01",
					false,
				)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1

			task.DueDate = "1971-01-01"
			Eventually(func() error {
				task, err = client.UpdateTask(*task)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1

			Eventually(func() error {
				_, err := client.CreateNote("myContent", task.ID)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1

			Eventually(func() error {
				return client.DeleteList(*newList)
			}).ShouldNot(HaveOccurred())

			Eventually(func() *[]wundergo.List {
				afterDeleteLists, err := client.Lists()
				Expect(err).ShouldNot(HaveOccurred())
				return afterDeleteLists
			}).Should(Equal(originalLists))
		})
	})
})<commit_msg>Wait longer for post-delete list checking in integration tests.<commit_after>package wundergo_test

import (
	"log"
	"os"
	"time"

	"github.com/nu7hatch/gouuid"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/robdimsdale/wundergo"
)

const (
	SERVER_CONSISTENCY_TIMEOUT = 5*time.Second
	POLLING_INTERVAL = 10*time.Millisecond
)
var (
	client wundergo.Client
)

func contains(lists *[]wundergo.List, list *wundergo.List) bool {
	for _, l := range *lists {
		if l == *list {
			return true
		}
	}
	return false
}

var _ = Describe("Wundergo library", func() {
	BeforeEach(func() {
		accessToken := os.Getenv("WL_ACCESS_TOKEN")
		clientID := os.Getenv("WL_CLIENT_ID")

		if accessToken == "" {
			log.Fatal("Error - WL_ACCESS_TOKEN must be provided")
		}

		if clientID == "" {
			log.Fatal("Error - WL_CLIENT_ID must be provided")
		}

		client = wundergo.NewOauthClient(accessToken, clientID)
	})

	Describe("Basic list functionality", func() {
		It("creates, updates and deletes new list", func() {
			uuid1, err := uuid.NewV4()
			Expect(err).NotTo(HaveOccurred())
			newListTitle1 := uuid1.String()

			uuid2, err := uuid.NewV4()
			Expect(err).NotTo(HaveOccurred())
			newListTitle2 := uuid2.String()

			var originalLists *[]wundergo.List
			Eventually(func() error {
				originalLists, err = client.Lists()
				return err
			}).ShouldNot(HaveOccurred())

			var newList *wundergo.List
			Eventually(func() error {
				newList, err = client.CreateList(newListTitle1)
				return err
			}).ShouldNot(HaveOccurred())

			var newLists *[]wundergo.List
			Eventually(func() error {
				newLists, err = client.Lists()
				return err
			}).ShouldNot(HaveOccurred())
			Expect(contains(newLists, newList)).To(BeTrue())

			newList.Title = newListTitle2
			var updatedList *wundergo.List
			Eventually(func() error {
				updatedList, err = client.UpdateList(*newList)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1
			Expect(updatedList).To(Equal(newList))

			Eventually(func() error {
				_, err = client.TasksForListID(newList.ID)
				return err
			}).ShouldNot(HaveOccurred())

			var task *wundergo.Task
			Eventually(func() error {
				task, err = client.CreateTask(
					"myTask",
					newList.ID,
					0,
					false,
					"",
					0,
					"1970-01-01",
					false,
				)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1

			task.DueDate = "1971-01-01"
			Eventually(func() error {
				task, err = client.UpdateTask(*task)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1

			Eventually(func() error {
				_, err := client.CreateNote("myContent", task.ID)
				return err
			}).ShouldNot(HaveOccurred())
			newList.Revision = newList.Revision + 1

			Eventually(func() error {
				return client.DeleteList(*newList)
			}).ShouldNot(HaveOccurred())

			Eventually(func() *[]wundergo.List {
				afterDeleteLists, err := client.Lists()
				Expect(err).ShouldNot(HaveOccurred())
				return afterDeleteLists
			}, SERVER_CONSISTENCY_TIMEOUT, POLLING_INTERVAL).Should(Equal(originalLists))
		})
	})
})
{'fraction_non_alphanumeric': 0.14065067367729214, 'fraction_numerical': 0.011337495892211634, 'mean_word_length': 3.56981981981982, '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': '5442617', 'n_tokens_mistral': 2585, 'n_tokens_neox': 2070, 'n_words': 407}