<commit_before>package main

import (
	"testing"

	"github.com/BytemarkHosting/bytemark-client/lib"
	"github.com/BytemarkHosting/bytemark-client/lib/brain"
	mock "github.com/maraino/go-mock"
	"github.com/urfave/cli"
)

var defVM = lib.VirtualMachineName{Group: "default", Account: "default-account"}
var defGroup = lib.GroupName{Group: "default", Account: "default-account"}

func init() {
	// If we are testing, we want to override the OsExiter,
	// so we can actually test errors returned from actions
	cli.OsExiter = func(c int) {}
}

func traverseAllCommands(cmds []cli.Command, fn func(cli.Command)) {
	if cmds == nil {
		return
	}
	for _, c := range cmds {
		fn(c)
		traverseAllCommands(c.Subcommands, fn)
	}
}

func getFixtureVM() brain.VirtualMachine {
	return brain.VirtualMachine{
		Name:     "test-server",
		Hostname: "test-server.test-group",
		GroupID:  1,
	}<commit_msg>- use the new Commands method to fetch list of commands - added a new traverse all commmands commands to provide more context to commands (especially admin commands) that may produce errors due to subcommands missing certain usage or description fields<commit_after>package main

import (
	"testing"

	"github.com/BytemarkHosting/bytemark-client/lib"
	"github.com/BytemarkHosting/bytemark-client/lib/brain"
	mock "github.com/maraino/go-mock"
	"github.com/urfave/cli"
)

var defVM = lib.VirtualMachineName{Group: "default", Account: "default-account"}
var defGroup = lib.GroupName{Group: "default", Account: "default-account"}

func init() {
	// If we are testing, we want to override the OsExiter,
	// so we can actually test errors returned from actions
	cli.OsExiter = func(c int) {}
}

func traverseAllCommands(cmds []cli.Command, fn func(cli.Command)) {
	if cmds == nil {
		return
	}
	for _, c := range cmds {
		fn(c)
		traverseAllCommands(c.Subcommands, fn)
	}
}

func traverseAllCommandsWithContext(cmds []cli.Command, name string, fn func(string, cli.Command)) {
	if cmds == nil {
		return
	}
	for _, c := range cmds {
		subName := name + " " + c.FullName()
		fn(subName, c)
		traverseAllCommandsWithContext(c.Subcommands, subName, fn)
	}
}

func getFixtureVM() brain.VirtualMachine {
	return brain.VirtualMachine{
		Name:     "test-server",
		Hostname: "test-server.test-group",
		GroupID:  1,
	}
{'fraction_non_alphanumeric': 0.1236347750109218, 'fraction_numerical': 0.0008737439930100481, 'mean_word_length': 4.350467289719626, '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': '2100159', 'n_tokens_mistral': 807, 'n_tokens_neox': 790, 'n_words': 207}