diff options
Diffstat (limited to 'vendor/google.golang.org/appengine/module')
-rw-r--r-- | vendor/google.golang.org/appengine/module/module.go | 113 | ||||
-rw-r--r-- | vendor/google.golang.org/appengine/module/module_test.go | 124 |
2 files changed, 0 insertions, 237 deletions
diff --git a/vendor/google.golang.org/appengine/module/module.go b/vendor/google.golang.org/appengine/module/module.go deleted file mode 100644 index 88e6629ac..000000000 --- a/vendor/google.golang.org/appengine/module/module.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2013 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -/* -Package module provides functions for interacting with modules. - -The appengine package contains functions that report the identity of the app, -including the module name. -*/ -package module // import "google.golang.org/appengine/module" - -import ( - "github.com/golang/protobuf/proto" - "golang.org/x/net/context" - - "google.golang.org/appengine/internal" - pb "google.golang.org/appengine/internal/modules" -) - -// List returns the names of modules belonging to this application. -func List(c context.Context) ([]string, error) { - req := &pb.GetModulesRequest{} - res := &pb.GetModulesResponse{} - err := internal.Call(c, "modules", "GetModules", req, res) - return res.Module, err -} - -// NumInstances returns the number of instances of the given module/version. -// If either argument is the empty string it means the default. -func NumInstances(c context.Context, module, version string) (int, error) { - req := &pb.GetNumInstancesRequest{} - if module != "" { - req.Module = &module - } - if version != "" { - req.Version = &version - } - res := &pb.GetNumInstancesResponse{} - - if err := internal.Call(c, "modules", "GetNumInstances", req, res); err != nil { - return 0, err - } - return int(*res.Instances), nil -} - -// SetNumInstances sets the number of instances of the given module.version to the -// specified value. If either module or version are the empty string it means the -// default. -func SetNumInstances(c context.Context, module, version string, instances int) error { - req := &pb.SetNumInstancesRequest{} - if module != "" { - req.Module = &module - } - if version != "" { - req.Version = &version - } - req.Instances = proto.Int64(int64(instances)) - res := &pb.SetNumInstancesResponse{} - return internal.Call(c, "modules", "SetNumInstances", req, res) -} - -// Versions returns the names of the versions that belong to the specified module. -// If module is the empty string, it means the default module. -func Versions(c context.Context, module string) ([]string, error) { - req := &pb.GetVersionsRequest{} - if module != "" { - req.Module = &module - } - res := &pb.GetVersionsResponse{} - err := internal.Call(c, "modules", "GetVersions", req, res) - return res.GetVersion(), err -} - -// DefaultVersion returns the default version of the specified module. -// If module is the empty string, it means the default module. -func DefaultVersion(c context.Context, module string) (string, error) { - req := &pb.GetDefaultVersionRequest{} - if module != "" { - req.Module = &module - } - res := &pb.GetDefaultVersionResponse{} - err := internal.Call(c, "modules", "GetDefaultVersion", req, res) - return res.GetVersion(), err -} - -// Start starts the specified version of the specified module. -// If either module or version are the empty string, it means the default. -func Start(c context.Context, module, version string) error { - req := &pb.StartModuleRequest{} - if module != "" { - req.Module = &module - } - if version != "" { - req.Version = &version - } - res := &pb.StartModuleResponse{} - return internal.Call(c, "modules", "StartModule", req, res) -} - -// Stop stops the specified version of the specified module. -// If either module or version are the empty string, it means the default. -func Stop(c context.Context, module, version string) error { - req := &pb.StopModuleRequest{} - if module != "" { - req.Module = &module - } - if version != "" { - req.Version = &version - } - res := &pb.StopModuleResponse{} - return internal.Call(c, "modules", "StopModule", req, res) -} diff --git a/vendor/google.golang.org/appengine/module/module_test.go b/vendor/google.golang.org/appengine/module/module_test.go deleted file mode 100644 index 73e8971dc..000000000 --- a/vendor/google.golang.org/appengine/module/module_test.go +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2013 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package module - -import ( - "reflect" - "testing" - - "github.com/golang/protobuf/proto" - - "google.golang.org/appengine/internal/aetesting" - pb "google.golang.org/appengine/internal/modules" -) - -const version = "test-version" -const module = "test-module" -const instances = 3 - -func TestList(t *testing.T) { - c := aetesting.FakeSingleContext(t, "modules", "GetModules", func(req *pb.GetModulesRequest, res *pb.GetModulesResponse) error { - res.Module = []string{"default", "mod1"} - return nil - }) - got, err := List(c) - if err != nil { - t.Fatalf("List: %v", err) - } - want := []string{"default", "mod1"} - if !reflect.DeepEqual(got, want) { - t.Errorf("List = %v, want %v", got, want) - } -} - -func TestSetNumInstances(t *testing.T) { - c := aetesting.FakeSingleContext(t, "modules", "SetNumInstances", func(req *pb.SetNumInstancesRequest, res *pb.SetNumInstancesResponse) error { - if *req.Module != module { - t.Errorf("Module = %v, want %v", req.Module, module) - } - if *req.Version != version { - t.Errorf("Version = %v, want %v", req.Version, version) - } - if *req.Instances != instances { - t.Errorf("Instances = %v, want %d", req.Instances, instances) - } - return nil - }) - err := SetNumInstances(c, module, version, instances) - if err != nil { - t.Fatalf("SetNumInstances: %v", err) - } -} - -func TestVersions(t *testing.T) { - c := aetesting.FakeSingleContext(t, "modules", "GetVersions", func(req *pb.GetVersionsRequest, res *pb.GetVersionsResponse) error { - if *req.Module != module { - t.Errorf("Module = %v, want %v", req.Module, module) - } - res.Version = []string{"v1", "v2", "v3"} - return nil - }) - got, err := Versions(c, module) - if err != nil { - t.Fatalf("Versions: %v", err) - } - want := []string{"v1", "v2", "v3"} - if !reflect.DeepEqual(got, want) { - t.Errorf("Versions = %v, want %v", got, want) - } -} - -func TestDefaultVersion(t *testing.T) { - c := aetesting.FakeSingleContext(t, "modules", "GetDefaultVersion", func(req *pb.GetDefaultVersionRequest, res *pb.GetDefaultVersionResponse) error { - if *req.Module != module { - t.Errorf("Module = %v, want %v", req.Module, module) - } - res.Version = proto.String(version) - return nil - }) - got, err := DefaultVersion(c, module) - if err != nil { - t.Fatalf("DefaultVersion: %v", err) - } - if got != version { - t.Errorf("Version = %v, want %v", got, version) - } -} - -func TestStart(t *testing.T) { - c := aetesting.FakeSingleContext(t, "modules", "StartModule", func(req *pb.StartModuleRequest, res *pb.StartModuleResponse) error { - if *req.Module != module { - t.Errorf("Module = %v, want %v", req.Module, module) - } - if *req.Version != version { - t.Errorf("Version = %v, want %v", req.Version, version) - } - return nil - }) - - err := Start(c, module, version) - if err != nil { - t.Fatalf("Start: %v", err) - } -} - -func TestStop(t *testing.T) { - c := aetesting.FakeSingleContext(t, "modules", "StopModule", func(req *pb.StopModuleRequest, res *pb.StopModuleResponse) error { - version := "test-version" - module := "test-module" - if *req.Module != module { - t.Errorf("Module = %v, want %v", req.Module, module) - } - if *req.Version != version { - t.Errorf("Version = %v, want %v", req.Version, version) - } - return nil - }) - - err := Stop(c, module, version) - if err != nil { - t.Fatalf("Stop: %v", err) - } -} |