当前位置: 首页>>代码示例>>Golang>>正文


Golang auth.ReserveApp函数代码示例

本文整理汇总了Golang中github.com/tsuru/tsuru/auth.ReserveApp函数的典型用法代码示例。如果您正苦于以下问题:Golang ReserveApp函数的具体用法?Golang ReserveApp怎么用?Golang ReserveApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReserveApp函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestReserveUserAppForwardAppNotPointer

func (s *S) TestReserveUserAppForwardAppNotPointer(c *gocheck.C) {
	user := auth.User{
		Email: "[email protected]",
		Quota: quota.Quota{Limit: 1},
	}
	err := user.Create()
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Users().Remove(bson.M{"email": user.Email})
	app := App{
		Name:     "clap",
		Platform: "django",
	}
	expected := map[string]string{"user": user.Email, "app": app.Name}
	previous, err := reserveUserApp.Forward(action.FWContext{Params: []interface{}{app, user}})
	c.Assert(err, gocheck.IsNil)
	c.Assert(previous, gocheck.DeepEquals, expected)
	err = auth.ReserveApp(&user)
	_, ok := err.(*quota.QuotaExceededError)
	c.Assert(ok, gocheck.Equals, true)
	err = auth.ReleaseApp(&user)
	c.Assert(err, gocheck.IsNil)
	err = auth.ReserveApp(&user)
	c.Assert(err, gocheck.IsNil)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:24,代码来源:actions_test.go

示例2: TestReserveUserAppBackward

func (s *S) TestReserveUserAppBackward(c *gocheck.C) {
	user := auth.User{
		Email: "[email protected]",
		Quota: quota.Quota{Limit: 1, InUse: 1},
	}
	err := user.Create()
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Users().Remove(bson.M{"email": user.Email})
	app := App{
		Name:     "clap",
		Platform: "django",
	}
	ctx := action.BWContext{
		FWResult: map[string]string{
			"app":  app.Name,
			"user": user.Email,
		},
	}
	reserveUserApp.Backward(ctx)
	err = auth.ReserveApp(&user)
	c.Assert(err, gocheck.IsNil)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:22,代码来源:actions_test.go

示例3:

			return nil, errors.New("First parameter must be *App.")
		}
		var user auth.User
		switch ctx.Params[1].(type) {
		case auth.User:
			user = ctx.Params[1].(auth.User)
		case *auth.User:
			user = *ctx.Params[1].(*auth.User)
		default:
			return nil, errors.New("Third parameter must be auth.User or *auth.User.")
		}
		usr, err := auth.GetUserByEmail(user.Email)
		if err != nil {
			return nil, err
		}
		if err := auth.ReserveApp(usr); err != nil {
			return nil, err
		}
		return map[string]string{"app": app.Name, "user": user.Email}, nil
	},
	Backward: func(ctx action.BWContext) {
		m := ctx.FWResult.(map[string]string)
		if user, err := auth.GetUserByEmail(m["user"]); err == nil {
			auth.ReleaseApp(user)
		}
	},
	MinParams: 2,
}

// insertApp is an action that inserts an app in the database in Forward and
// removes it in the Backward.
开发者ID:edulemasson,项目名称:tsuru,代码行数:31,代码来源:actions.go


注:本文中的github.com/tsuru/tsuru/auth.ReserveApp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。