<commit_before>// Copyright 2018 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package app

import (
	"context"

	"gopkg.in/check.v1"
)

func (s *S) TestAppRouterUpdaterUpdateWait(c *check.C) {
	a := App{
		Name:      "app1",
		TeamOwner: s.team.Name,
	}
	err := CreateApp(&a, s.user)
	c.Assert(err, check.IsNil)
	updater := GetAppRouterUpdater()
	updater.update(&a)
	err = updater.Shutdown(context.Background())
	c.Assert(err, check.IsNil)
	apps, err := List(nil)
	c.Assert(err, check.IsNil)
	c.Assert(apps, check.HasLen, 1)
	c.Assert(apps[0].Routers[0].Address, check.Equals, "app1.fakerouter.com")
}
<commit_msg>app/routerupdater: add MockCacheService to test<commit_after>// Copyright 2018 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package app

import (
	"context"

	appTypes "github.com/tsuru/tsuru/types/app"
	"gopkg.in/check.v1"
)

func (s *S) TestAppRouterUpdaterUpdateWait(c *check.C) {
	s.mockService.Cache.OnList = func(keys ...string) ([]appTypes.CacheEntry, error) {
		return []appTypes.CacheEntry{
			{Key: "app-router-addr\x00app1\x00fake", Value: "app1.fakerouter.com"},
		}, nil
	}
	a := App{
		Name:      "app1",
		TeamOwner: s.team.Name,
	}
	err := CreateApp(&a, s.user)
	c.Assert(err, check.IsNil)
	updater := GetAppRouterUpdater()
	updater.update(&a)
	err = updater.Shutdown(context.Background())
	c.Assert(err, check.IsNil)
	apps, err := List(nil)
	c.Assert(err, check.IsNil)
	c.Assert(apps, check.HasLen, 1)
	c.Assert(apps[0].Routers[0].Address, check.Equals, "app1.fakerouter.com")
}

{'fraction_non_alphanumeric': 0.15393654524089306, 'fraction_numerical': 0.01527614571092832, 'mean_word_length': 4.145015105740181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978384', 'n_tokens_mistral': 678, 'n_tokens_neox': 664, 'n_words': 150}