Esempio n. 1
0
func TestFindNextRoomNilFromRoom(t *testing.T) {
	c1 := slack.Channel{}
	c1.ID = "room1"
	c1.Name = "room1"
	w := &Wicked{
		bot: &slick.Bot{Channels: map[string]slack.Channel{
			"room1": c1,
		}},
		meetings:  map[string]*Meeting{},
		confRooms: []string{"room1"},
	}

	res := w.FindAvailableRoom("")

	if res == nil {
		t.Fail()
	}
	if res.ID != "room1" {
		t.Error(`Should be "room1"`)
	}
}
Esempio n. 2
0
func TestFindNextRoom(t *testing.T) {
	c2 := slack.Channel{}
	c2.ID = "room2"
	c2.Name = "room2"
	c3 := slack.Channel{}
	c3.ID = "room3"
	c3.Name = "room3"

	w := &Wicked{
		bot: &slick.Bot{Channels: map[string]slack.Channel{
			"room2": c2,
			"room3": c3,
		}},
		meetings: map[string]*Meeting{
			"room1": &Meeting{},
		},
		confRooms: []string{
			"room1",
			"room2",
			"room3",
		},
	}

	res := w.FindAvailableRoom("other")

	if res == nil {
		t.Fail()
	}
	if res.ID != "room2" {
		t.Error(`Should be "room2"`)
	}

	res = w.FindAvailableRoom("room3")

	if res == nil {
		t.Fail()
	}
	if res.ID != "room3" {
		t.Error(`Should be "room3"`)
	}
}
Esempio n. 3
0
func dumpRooms(api *slack.Client, dir string, rooms []string) {
	// Dump Channels
	channels := dumpChannels(api, dir, rooms)

	// Dump Private Groups
	groups := dumpGroups(api, dir, rooms)

	if len(groups) > 0 {
		for _, group := range groups {
			channel := slack.Channel{}
			channel.ID = group.Conversation.ID
			channel.Name = group.Name
			channel.Created = group.Created
			channel.Creator = group.Creator
			channel.IsArchived = group.IsArchived
			channel.IsChannel = true
			channel.IsGeneral = false
			channel.IsMember = true
			channel.LastRead = group.LastRead
			channel.Latest = group.Latest
			channel.Members = group.Members
			channel.NumMembers = group.NumMembers
			channel.Purpose = group.Purpose
			channel.Topic = group.Topic
			channel.UnreadCount = group.UnreadCount
			channel.UnreadCountDisplay = group.UnreadCountDisplay
			channels = append(channels, channel)
		}
	}

	data, err := MarshalIndent(channels, "", "    ")
	check(err)
	err = ioutil.WriteFile(path.Join(dir, "channels.json"), data, 0644)
	check(err)
}