Exemplo n.º 1
0
func TestParams(t *testing.T) {
	cases := []struct {
		Params   []fbapi.Param
		Expected url.Values
	}{
		{
			Params:   []fbapi.Param{fbapi.ParamLimit(42)},
			Expected: url.Values{"limit": []string{"42"}},
		},
		{
			Params:   []fbapi.Param{fbapi.ParamOffset(42)},
			Expected: url.Values{"offset": []string{"42"}},
		},
		{
			Params:   []fbapi.Param{fbapi.ParamFields("abc", "def")},
			Expected: url.Values{"fields": []string{"abc,def"}},
		},
		{
			Params:   []fbapi.Param{fbapi.ParamAccessToken("42")},
			Expected: url.Values{"access_token": []string{"42"}},
		},
		{
			Params:   []fbapi.Param{fbapi.ParamDateFormat("42")},
			Expected: url.Values{"date_format": []string{"42"}},
		},
	}

	for _, c := range cases {
		v, err := fbapi.ParamValues(c.Params...)
		if err != nil {
			t.Errorf("case %+v got error %s", c, err)
		}
		if !reflect.DeepEqual(c.Expected, v) {
			t.Fatalf("case\n%+v\nactual:\n%+v", c, v)
		}
	}
}
Exemplo n.º 2
0
// Package empcheck checks for employees.
package empcheck

import (
	"net/http"
	"net/url"
	"strconv"

	"github.com/daaku/rell/internal/github.com/facebookgo/fbapi"
	"github.com/daaku/rell/internal/github.com/facebookgo/fbapp"
	"github.com/daaku/rell/internal/github.com/golang/groupcache/lru"
)

var fields = fbapi.ParamFields("is_employee")

type cacheKey uint64

type user struct {
	IsEmployee bool `json:"is_employee"`
}

type Logger interface {
	Printf(format string, v ...interface{})
}

type Checker struct {
	FbApiClient *fbapi.Client
	App         fbapp.App
	Logger      Logger
	Cache       *lru.Cache
}