• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang client.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestDeliveryServiceState

func TestDeliveryServiceState(t *testing.T) {
	resp := fixtures.DeliveryServiceState()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceState")

	state, err := to.DeliveryServiceState("123")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if state.Failover.Destination.Location != "someLocation" {
		testHelper.Error(t, "Should get back \"someLocation\" for \"Failover.Destination.Location\", got: %s", state.Failover.Destination.Location)
	} else {
		testHelper.Success(t, "Should get back \"someLocation\" for \"Failover.Destination.Location\"")
	}

	if state.Enabled != true {
		testHelper.Error(t, "Should get back \"true\" for \"Enabled\", got: %s", state.Enabled)
	} else {
		testHelper.Success(t, "Should get back \"true\" for \"Enabled\"")
	}
}
开发者ID:robert-butts,项目名称:traffic_control,代码行数:32,代码来源:delivery_service_test.go


示例2: getDeliveryServiceServers

// getDeliveryServiceServers gets the servers on each delivery services, for the given CDN, from Traffic Ops.
// Returns a map[deliveryService][]server, and a map[server]deliveryService
func getDeliveryServiceServers(to *traffic_ops.Session, cdn string) (map[string][]string, map[string]string, error) {
	dsServers := map[string][]string{}
	serverDs := map[string]string{}

	crcData, err := to.CRConfigRaw(cdn)
	if err != nil {
		return nil, nil, err
	}
	type CrConfig struct {
		ContentServers map[string]struct {
			DeliveryServices map[string][]string `json:"deliveryServices"`
		} `json:"contentServers"`
	}
	var crc CrConfig
	if err := json.Unmarshal(crcData, &crc); err != nil {
		return nil, nil, err
	}

	for serverName, serverData := range crc.ContentServers {
		for deliveryServiceName, _ := range serverData.DeliveryServices {
			dsServers[deliveryServiceName] = append(dsServers[deliveryServiceName], serverName)
			serverDs[serverName] = deliveryServiceName
		}
	}
	return dsServers, serverDs, nil
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:28,代码来源:manager.go


示例3: TestTypes

func TestTypes(t *testing.T) {
	resp := fixtures.Types()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Types")

	types, err := to.Types()
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	for _, n := range types {
		if n.Name != "EDGE" {
			testHelper.Error(t, "Should get back \"EDGE\" for \"Name\", got %s", n.Name)
		} else {
			testHelper.Success(t, "Should get back \"EDGE\" for \"Name\"")
		}

		if n.Description != "edge cache" {
			testHelper.Error(t, "Should get back \"edge cache\" for \"Description\", got %s", n.Description)
		} else {
			testHelper.Success(t, "Should get back \"edge cache\" for \"Description\"")
		}
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:34,代码来源:type_test.go


示例4: getDeliveryServiceTypes

func getDeliveryServiceTypes(to *traffic_ops.Session, cdn string) (map[string]deliveryservicestats.DsStatType, error) {
	dsTypes := map[string]deliveryservicestats.DsStatType{}

	crcData, err := to.CRConfigRaw(cdn)
	if err != nil {
		return nil, err
	}
	type CrConfig struct {
		DeliveryServices map[string]struct {
			Matchsets []struct {
				Protocol string `json:"protocol"`
			} `json:"matchsets"`
		} `json:"deliveryServices"`
	}
	var crc CrConfig
	if err := json.Unmarshal(crcData, &crc); err != nil {
		return nil, fmt.Errorf("Error unmarshalling CRConfig: %v", err)
	}

	for dsName, dsData := range crc.DeliveryServices {
		if len(dsData.Matchsets) < 1 {
			return nil, fmt.Errorf("CRConfig missing protocol for '%s'", dsName)
		}
		dsTypeStr := dsData.Matchsets[0].Protocol
		dsType := deliveryservicestats.DsStatTypeFromString(dsTypeStr)
		if dsType == deliveryservicestats.DsStatTypeInvalid {
			return nil, fmt.Errorf("CRConfig unknowng protocol for '%s': '%s'", dsName, dsTypeStr)
		}
		dsTypes[dsName] = dsType
	}
	return dsTypes, nil
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:32,代码来源:manager.go


示例5: TestServerFQDN

func TestServerFQDN(t *testing.T) {
	resp := fixtures.Servers()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	shortName := "edge-alb-01"
	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for the FQDN of Server: \"%s\"", shortName)

	s, err := to.ServersFqdn("edge-alb-01")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if s != "edge-alb-01.albuquerque.nm.albuq.kabletown.com" {
		testHelper.Error(t, "Should get back \"edge-alb-01.albuquerque.nm.albuq.kabletown.com\", got: %s", s)
	} else {
		testHelper.Success(t, "Should get back \"edge-alb-01.albuquerque.nm.albuq.kabletown.com\"")
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:27,代码来源:server_test.go


示例6: TestServerShortName

func TestServerShortName(t *testing.T) {
	resp := fixtures.Servers()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	pattern := "edge"
	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for servers that match Short Name: \"%s\"", pattern)

	servers, err := to.ServersShortNameSearch(pattern)
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if servers[0] != "edge-alb-01" {
		testHelper.Error(t, "Should get back \"edge-alb-01\", got: %s", servers[0])
	} else {
		testHelper.Success(t, "Should get back \"edge-alb-01\"")
	}

	if servers[1] != "edge-alb-02" {
		testHelper.Error(t, "Should get back \"edge-alb-02\", got: %s", servers[1])
	} else {
		testHelper.Success(t, "Should get back \"edge-alb-02\"")
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:33,代码来源:server_test.go


示例7: TestDeliveryServiceRouting

func TestDeliveryServiceRouting(t *testing.T) {
	resp := fixtures.DeliveryServiceRouting()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceRouting")

	routing, err := to.DeliveryServiceRouting("123")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if routing.StaticRoute != 1 {
		testHelper.Error(t, "Should get back \"1\" for \"StaticRoute\", got: %s", routing.StaticRoute)
	} else {
		testHelper.Success(t, "Should get back \"1\" for \"StaticRoute\"")
	}
}
开发者ID:robert-butts,项目名称:traffic_control,代码行数:26,代码来源:delivery_service_test.go


示例8: TestDeliveryService

func TestDeliveryService(t *testing.T) {
	resp := fixtures.DeliveryServices()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryService")

	ds, err := to.DeliveryService("123")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if ds.XMLID != "ds-test" {
		testHelper.Error(t, "Should get back \"ds-test\" for \"XMLID\", got: %s", ds.XMLID)
	} else {
		testHelper.Success(t, "Should get back \"ds-test\" for \"XMLID\"")
	}

	if ds.MissLong != "-99.123456" {
		testHelper.Error(t, "Should get back \"-99.123456\" for \"MissLong\", got: %s", ds.MissLong)
	} else {
		testHelper.Success(t, "Should get back \"-99.123456\" for \"MissLong\"")
	}
}
开发者ID:robert-butts,项目名称:traffic_control,代码行数:32,代码来源:delivery_service_test.go


示例9: getServerTypes

// getServerTypes gets the cache type of each ATS Edge+Mid Cache server, for the given CDN, from Traffic Ops.
func getServerTypes(to *traffic_ops.Session, cdn string) (map[string]deliveryservicestats.DsStatCacheType, error) {
	serverTypes := map[string]deliveryservicestats.DsStatCacheType{}

	crcData, err := to.CRConfigRaw(cdn)
	if err != nil {
		return nil, err
	}
	type CrConfig struct {
		ContentServers map[string]struct {
			Type string `json:"type"`
		} `json:"contentServers"`
	}
	var crc CrConfig
	if err := json.Unmarshal(crcData, &crc); err != nil {
		return nil, err
	}

	for server, serverData := range crc.ContentServers {
		t := deliveryservicestats.DsStatCacheTypeFromString(serverData.Type)
		if t == deliveryservicestats.DsStatCacheTypeInvalid {
			return nil, fmt.Errorf("getServerTypes CRConfig unknown type for '%s': '%s'", server, serverData.Type)
		}
		serverTypes[server] = t
	}
	return serverTypes, nil
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:27,代码来源:manager.go


示例10: getDeliveryServiceRegexes

// getDeliveryServiceRegexes gets the regexes of each delivery service, for the given CDN, from Traffic Ops.
// Returns a map[deliveryService][]regex.
func getDeliveryServiceRegexes(to *traffic_ops.Session, cdn string) (map[string][]string, error) {
	dsRegexes := map[string][]string{}

	crcData, err := to.CRConfigRaw(cdn)
	if err != nil {
		return nil, err
	}
	type CrConfig struct {
		DeliveryServices map[string]struct {
			Matchsets []struct {
				MatchList []struct {
					Regex string `json:"regex"`
				} `json:"matchlist"`
			} `json:"matchsets"`
		} `json:"deliveryServices"`
	}
	var crc CrConfig
	if err := json.Unmarshal(crcData, &crc); err != nil {
		return nil, err
	}

	for dsName, dsData := range crc.DeliveryServices {
		if len(dsData.Matchsets) < 1 {
			return nil, fmt.Errorf("CRConfig missing regex for '%s'", dsName)
		}
		for _, matchset := range dsData.Matchsets {
			if len(matchset.MatchList) < 1 {
				return nil, fmt.Errorf("CRConfig missing Regex for '%s'", dsName)
			}
			dsRegexes[dsName] = append(dsRegexes[dsName], matchset.MatchList[0].Regex)
		}
	}
	return dsRegexes, nil
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:36,代码来源:manager.go


示例11: getServerTypes

func getServerTypes(to *traffic_ops.Session, cdn string) (map[string]string, error) {
	// This is efficient (with getDeliveryServiceServers) because the traffic_ops client caches its result.
	// Were that not the case, these functions could be refactored to only call traffic_ops.Session.CRConfigRaw() once.

	crcData, err := to.CRConfigRaw(cdn)
	if err != nil {
		return nil, err
	}

	type CrConfig struct {
		ContentServers map[string]struct {
			Type string `json:"type"`
		} `json:"contentServers"`
	}
	var crc CrConfig
	if err := json.Unmarshal(crcData, &crc); err != nil {
		return nil, err
	}

	serverTypes := map[string]string{}
	for serverName, serverData := range crc.ContentServers {
		serverTypes[serverName] = serverData.Type
	}
	return serverTypes, nil
}
开发者ID:carriercomm,项目名称:traffic_control,代码行数:25,代码来源:manager.go


示例12: TestUsers

func TestUsers(t *testing.T) {
	resp := fixtures.Users()
	server := testHelper.ValidHTTPServer(resp.Response)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Users")

	users, err := to.Users()
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	for _, u := range users {
		if u.FullName != "Bob Smith" {
			testHelper.Error(t, "Should get back \"Bob Smith\" for \"FullName\", got %s", u.FullName)
		} else {
			testHelper.Success(t, "Should get back \"Bob Smith\" for \"FullName\"")
		}

		if u.PublicSSHKey != "some-ssh-key" {
			testHelper.Error(t, "Should get back \"some-ssh-key\" for \"PublicSSHKey\", got %s", u.PublicSSHKey)
		} else {
			testHelper.Success(t, "Should get back \"some-ssh-key\" for \"PublicSSHKey\"")
		}

		if u.Role != "3" {
			testHelper.Error(t, "Should get back \"3\" for \"Role\", got %s", u.Role)
		} else {
			testHelper.Success(t, "Should get back \"3\" for \"Role\"")
		}

		if u.Email != "[email protected]" {
			testHelper.Error(t, "Should get back \"[email protected]\" for \"Email\", got %s", u.Email)
		} else {
			testHelper.Success(t, "Should get back \"[email protected]\" for \"Email\"")
		}

		if u.Username != "bsmith" {
			testHelper.Error(t, "Should get back \"bsmith\" for \"Username\", got %s", u.Username)
		} else {
			testHelper.Success(t, "Should get back \"bsmith\" for \"Username\"")
		}
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:52,代码来源:user_test.go


示例13: TestCacheGroup

func TestCacheGroup(t *testing.T) {
	resp := fixtures.Cachegroups()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for CacheGroups")

	cacheGroups, err := to.CacheGroups()
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if len(cacheGroups) != 1 {
		testHelper.Error(t, "Should get back \"1\" CacheGroups, got: %d", len(cacheGroups))
	} else {
		testHelper.Success(t, "Should get back \"1\" CacheGroups")
	}

	for _, cacheGroup := range cacheGroups {
		if cacheGroup.Name == "" {
			testHelper.Error(t, "Should get back \"edge-philadelphia\" for \"Name\", got: %s", cacheGroup.Name)
		} else {
			testHelper.Success(t, "Should get back \"edge-philadelphia\" for \"Name\"")
		}

		if cacheGroup.Longitude != 5 {
			testHelper.Error(t, "Should get back \"5\" for \"Longitude\", got: %v", cacheGroup.Longitude)
		} else {
			testHelper.Success(t, "Should get back \"5\" for \"Longitude\"")
		}

		if cacheGroup.Latitude != 55 {
			testHelper.Error(t, "Should get back \"55\" for \"Latitude\", got: %v", cacheGroup.Latitude)
		} else {
			testHelper.Success(t, "Should get back \"55\" for \"Latitude\"")
		}

		if cacheGroup.ParentName != "mid-northeast" {
			testHelper.Error(t, "Should get back \"mid-northeast\" for \"ParentName\", got: %s", cacheGroup.ParentName)
		} else {
			testHelper.Success(t, "Should get back \"mid-northeast\" for \"ParentName\"")
		}
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:52,代码来源:cachegroup_test.go


示例14: TestStatsSummary

func TestStatsSummary(t *testing.T) {
	resp := fixtures.StatsSummary()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Stats Summary")

	stats, err := to.SummaryStats("test-cdn", "test-ds1", "test-stat")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if len(stats) != 1 {
		testHelper.Error(t, "Should get back \"1\" Parameter, got: %d", len(stats))
	} else {
		testHelper.Success(t, "Should get back \"1\" Parameter")
	}

	for _, s := range stats {
		if s.StatName != "test-stat" {
			testHelper.Error(t, "Should get back \"test-stat\" for \"StatName\", got: %s", s.StatName)
		} else {
			testHelper.Success(t, "Should get back \"test-stat\" for \"StatName\"")
		}

		if s.DeliveryService != "test-ds1" {
			testHelper.Error(t, "Should get back \"test-ds1\" for \"DeliveryService\", got: %s", s.DeliveryService)
		} else {
			testHelper.Success(t, "Should get back \"test-ds1\" for \"DeliveryService\"")
		}

		if s.StatValue != "3.1415" {
			testHelper.Error(t, "Should get back \"3.1415\" for \"StatValue\", got: %s", s.StatValue)
		} else {
			testHelper.Success(t, "Should get back \"3.1415\" for \"StatValue\"")
		}

		if s.CDNName != "test-cdn" {
			testHelper.Error(t, "Should get back \"test-cdn\" for \"CDNName\", got: %s", s.CDNName)
		} else {
			testHelper.Success(t, "Should get back \"test-cdn\" for \"CDNName\"")
		}
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:52,代码来源:stats_summary_test.go


示例15: TestServerByType

func TestServerByType(t *testing.T) {
	resp := fixtures.LogstashServers()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for \"Logstash\" Servers")

	params := make(url.Values)
	params.Add("type", "Logstash")

	servers, err := to.ServersByType(params)
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if len(servers) != 2 {
		testHelper.Error(t, "Should get back \"2\" Server, got: %d", len(servers))
	} else {
		testHelper.Success(t, "Should get back \"2\" Server")
	}

	if servers[0].HostName != "logstash-01" {
		testHelper.Error(t, "Should get \"logstash-01\" for \"HostName\", got: %s", servers[0].HostName)
	} else {
		testHelper.Success(t, "Should get \"logstash-01\" for \"HostName\"")
	}

	if servers[0].DomainName != "albuquerque.nm.albuq.kabletown.com" {
		testHelper.Error(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\", got: %s", servers[0].DomainName)
	} else {
		testHelper.Success(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\"")
	}

	if servers[0].Type != "LOGSTASH" {
		testHelper.Error(t, "Should get \"LOGSTASH\" for \"Type\", got: %s", servers[0].Type)
	} else {
		testHelper.Success(t, "Should get \"LOGSTASH\" for \"Type\"")
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:47,代码来源:server_test.go


示例16: TestHardware

func TestHardware(t *testing.T) {
	resp := fixtures.Hardware()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Hardware")

	hardware, err := to.Hardware()
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if len(hardware) != 1 {
		testHelper.Error(t, "Should get back \"1\" Hardware, got: %d", len(hardware))
	} else {
		testHelper.Success(t, "Should get back \"1\" Hardware")
	}

	for _, h := range hardware {
		if h.HostName != "odol-atsmid-cen-09" {
			testHelper.Error(t, "Should get back \"odol-atsmid-cen-09\" for \"Hostname\", got: %s", h.HostName)
		} else {
			testHelper.Success(t, "Should get back \"odol-atsmid-cen-09\" for \"Hostname\"")
		}

		if h.Value != "1.00" {
			testHelper.Error(t, "Should get back \"1.00\" for \"Value\", got: %s", h.Value)
		} else {
			testHelper.Success(t, "Should get back \"1.00\" for \"Value\"")
		}

		if h.Description != "BACKPLANE FIRMWARE" {
			testHelper.Error(t, "Should get back \"BACKPLANE FIRMWARE\" for \"Description\", got: %s", h.Description)
		} else {
			testHelper.Success(t, "Should get back \"BACKPLANE FIRMWARE\" for \"Description\"")
		}
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:46,代码来源:hardware_test.go


示例17: TestParameters

func TestParameters(t *testing.T) {
	resp := fixtures.Parameters()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Parameters")

	parameters, err := to.Parameters("test")
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if len(parameters) != 1 {
		testHelper.Error(t, "Should get back \"1\" Parameter, got: %d", len(parameters))
	} else {
		testHelper.Success(t, "Should get back \"1\" Parameter")
	}

	for _, param := range parameters {
		if param.Name != "location" {
			testHelper.Error(t, "Should get back \"location\" for \"Name\", got: %s", param.Name)
		} else {
			testHelper.Success(t, "Should get back \"location\" for \"Name\"")
		}

		if param.Value != "/foo/trafficserver/" {
			testHelper.Error(t, "Should get back \"/foo/trafficserver/\" for \"Value\", got: %s", param.Value)
		} else {
			testHelper.Success(t, "Should get back \"/foo/trafficserver/\" for \"Value\"")
		}

		if param.ConfigFile != "parent.config" {
			testHelper.Error(t, "Should get back \"parent.config\" for \"ConfigFile\", got: %s", param.ConfigFile)
		} else {
			testHelper.Success(t, "Should get back \"parent.config\" for \"ConfigFile\"")
		}
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:46,代码来源:parameter_test.go


示例18: TestServer

func TestServer(t *testing.T) {
	resp := fixtures.Servers()
	server := testHelper.ValidHTTPServer(resp)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Servers")

	servers, err := to.Servers()
	if err != nil {
		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should be able to make a request to Traffic Ops")
	}

	if len(servers) != 3 {
		testHelper.Error(t, "Should get back \"3\" Server, got: %d", len(servers))
	} else {
		testHelper.Success(t, "Should get back \"3\" Server")
	}

	if servers[0].HostName != "edge-alb-01" {
		testHelper.Error(t, "Should get \"edge-alb-01\" for \"HostName\", got: %s", servers[0].HostName)
	} else {
		testHelper.Success(t, "Should get \"edge-alb-01\" for \"HostName\"")
	}

	if servers[0].DomainName != "albuquerque.nm.albuq.kabletown.com" {
		testHelper.Error(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\", got: %s", servers[0].DomainName)
	} else {
		testHelper.Success(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\"")
	}

	if servers[0].Type != "EDGE" {
		testHelper.Error(t, "Should get \"EDGE\" for \"Type\", got: %s", servers[0].Type)
	} else {
		testHelper.Success(t, "Should get \"EDGE\" for \"Type\"")
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:44,代码来源:server_test.go


示例19: TestServersUnauthorized

func TestServersUnauthorized(t *testing.T) {
	server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Servers")

	_, err := to.Servers()
	if err == nil {
		testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:19,代码来源:server_test.go


示例20: TestServerFQDNUnauthorized

func TestServerFQDNUnauthorized(t *testing.T) {
	server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
	defer server.Close()

	var httpClient http.Client
	to := client.Session{
		URL:       server.URL,
		UserAgent: &httpClient,
	}

	shortName := "edge-alb-01"
	testHelper.Context(t, "Given the need to test a failed Traffic Ops request for the FQDN of Server: \"%s\"", shortName)

	_, err := to.ServersFqdn(shortName)
	if err == nil {
		testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
	} else {
		testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
	}
}
开发者ID:CadeLaRen,项目名称:traffic_control,代码行数:20,代码来源:server_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang client.StatsSummary类代码示例发布时间:2022-05-23
下一篇:
Golang client.Login函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap