blob: a49b83ef94a3681efe3f5e6e0ca654c28af5bb3f [file] [log] [blame]
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
package main
import (
func TestFlashMessages(t *testing.T) {
resp := httptest.NewRecorder()
expectedMessages := []flashMessage{
{ID: "a", Args: []string{"one"}},
{ID: "b", Args: []string{"two", "three"}},
{ID: "c", Args: []string{}},
setFlashMessages(resp, expectedMessages)
req := &http.Request{Header: http.Header{"Cookie": {strings.Split(resp.Header().Get("Set-Cookie"), ";")[0]}}}
actualMessages := getFlashMessages(resp, req)
if !cmp.Equal(actualMessages, expectedMessages) {
t.Errorf("got messages %+v, want %+v", actualMessages, expectedMessages)